
// this is autogenerated file, do not edit it.
#include "ficus/ficus.h"

struct _fx_Nt6option1N10Ast__typ_t_data_t;

static void _fx_free_Nt6option1N10Ast__typ_t(struct _fx_Nt6option1N10Ast__typ_t_data_t** dst);

struct _fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t_data_t;

static void _fx_free_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t(
   struct _fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t_data_t** dst);

struct _fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t_data_t;

static void _fx_free_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t(
   struct _fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t_data_t** dst);

struct _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_data_t;

static void _fx_free_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   struct _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_data_t** dst);

struct _fx_Nt6option1N10Ast__exp_t_data_t;

static void _fx_free_Nt6option1N10Ast__exp_t(struct _fx_Nt6option1N10Ast__exp_t_data_t** dst);

struct _fx_Nt10Hashset__t1R9Ast__id_t_data_t;

static void _fx_free_Nt10Hashset__t1R9Ast__id_t(struct _fx_Nt10Hashset__t1R9Ast__id_t_data_t** dst);

struct _fx_Nt9Dynvec__t1N14Ast__id_info_t_data_t;

static void _fx_free_Nt9Dynvec__t1N14Ast__id_info_t(struct _fx_Nt9Dynvec__t1N14Ast__id_info_t_data_t** dst);

struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t;

static void _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t** dst);

struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t;

static void _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t** dst);

struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t;

static void _fx_free_Nt11Set__tree_t1R9Ast__id_t(struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t** dst);

struct _fx_N10Ast__typ_t_data_t;

static void _fx_free_N10Ast__typ_t(struct _fx_N10Ast__typ_t_data_t** dst);

struct _fx_N13Ast__binary_t_data_t;

static void _fx_free_N13Ast__binary_t(struct _fx_N13Ast__binary_t_data_t** dst);

struct _fx_N10Ast__exp_t_data_t;

static void _fx_free_N10Ast__exp_t(struct _fx_N10Ast__exp_t_data_t** dst);

struct _fx_N10Ast__pat_t_data_t;

static void _fx_free_N10Ast__pat_t(struct _fx_N10Ast__pat_t_data_t** dst);

struct _fx_N16Ast__env_entry_t_data_t;

static void _fx_free_N16Ast__env_entry_t(struct _fx_N16Ast__env_entry_t_data_t** dst);

struct _fx_N16Ast__defmodule_t_data_t;

static void _fx_free_N16Ast__defmodule_t(struct _fx_N16Ast__defmodule_t_data_t** dst);

typedef struct _fx_Nt6option1N10Ast__typ_t_data_t {
   int_ rc;
   union {
      struct _fx_N10Ast__typ_t_data_t* Some;
   } u;
} _fx_Nt6option1N10Ast__typ_t_data_t, *_fx_Nt6option1N10Ast__typ_t;

typedef struct _fx_LS_data_t {
   int_ rc;
   struct _fx_LS_data_t* tl;
   fx_str_t hd;
} _fx_LS_data_t, *_fx_LS;

typedef struct _fx_N17Options__optval_t {
   int tag;
   union {
      bool OptBool;
      int_ OptInt;
      fx_str_t OptString;
   } u;
} _fx_N17Options__optval_t;

typedef struct _fx_T2SN17Options__optval_t {
   fx_str_t t0;
   struct _fx_N17Options__optval_t t1;
} _fx_T2SN17Options__optval_t;

typedef struct _fx_LT2SN17Options__optval_t_data_t {
   int_ rc;
   struct _fx_LT2SN17Options__optval_t_data_t* tl;
   struct _fx_T2SN17Options__optval_t hd;
} _fx_LT2SN17Options__optval_t_data_t, *_fx_LT2SN17Options__optval_t;

typedef struct _fx_R18Options__options_t {
   struct _fx_LS_data_t* app_args;
   fx_str_t app_filename;
   bool arch64;
   bool force_rebuild;
   fx_str_t build_dir;
   fx_str_t build_rootdir;
   fx_str_t cflags;
   fx_str_t clibs;
   bool compile_by_cpp;
   fx_str_t filename;
   bool gen_c;
   struct _fx_LS_data_t* include_path;
   bool debug;
   struct _fx_LT2SN17Options__optval_t_data_t* defines;
   int_ optim_iters;
   int_ inline_thresh;
   bool enable_openmp;
   bool relax;
   bool use_preamble;
   bool make_app;
   int_ optimize_level;
   fx_str_t output_name;
   bool print_ast0;
   bool print_ast;
   bool print_k0;
   bool print_k;
   bool print_tokens;
   bool run_app;
   bool verbose;
   bool W_unused;
} _fx_R18Options__options_t;

typedef struct _fx_Ta2i {
   int_ t0;
   int_ t1;
} _fx_Ta2i;

typedef struct _fx_T2Ta2iS {
   struct _fx_Ta2i t0;
   fx_str_t t1;
} _fx_T2Ta2iS;

typedef struct _fx_R9Ast__id_t {
   int_ m;
   int_ i;
   int_ j;
} _fx_R9Ast__id_t;

typedef struct _fx_R10Ast__loc_t {
   int_ m_idx;
   int_ line0;
   int_ col0;
   int_ line1;
   int_ col1;
} _fx_R10Ast__loc_t;

typedef struct _fx_T2R9Ast__id_ti {
   struct _fx_R9Ast__id_t t0;
   int_ t1;
} _fx_T2R9Ast__id_ti;

typedef struct _fx_T2Bi {
   bool t0;
   int_ t1;
} _fx_T2Bi;

typedef struct _fx_N12Ast__scope_t {
   int tag;
   union {
      int_ ScBlock;
      struct _fx_T2Bi ScLoop;
      int_ ScFold;
      int_ ScArrMap;
      int_ ScMap;
      int_ ScTry;
      struct _fx_R9Ast__id_t ScFun;
      struct _fx_R9Ast__id_t ScClass;
      struct _fx_R9Ast__id_t ScInterface;
      int_ ScModule;
   } u;
} _fx_N12Ast__scope_t;

typedef struct _fx_LN12Ast__scope_t_data_t {
   int_ rc;
   struct _fx_LN12Ast__scope_t_data_t* tl;
   struct _fx_N12Ast__scope_t hd;
} _fx_LN12Ast__scope_t_data_t, *_fx_LN12Ast__scope_t;

typedef struct _fx_R16Ast__val_flags_t {
   bool val_flag_arg;
   bool val_flag_mutable;
   bool val_flag_temp;
   bool val_flag_tempref;
   bool val_flag_private;
   bool val_flag_subarray;
   bool val_flag_instance;
   struct _fx_T2R9Ast__id_ti val_flag_method;
   int_ val_flag_ctor;
   struct _fx_LN12Ast__scope_t_data_t* val_flag_global;
} _fx_R16Ast__val_flags_t;

typedef struct _fx_N17Ast__fun_constr_t {
   int tag;
   union {
      int_ CtorVariant;
      struct _fx_R9Ast__id_t CtorFP;
      struct _fx_R9Ast__id_t CtorExn;
   } u;
} _fx_N17Ast__fun_constr_t;

typedef struct _fx_R16Ast__fun_flags_t {
   int_ fun_flag_pure;
   bool fun_flag_ccode;
   bool fun_flag_have_keywords;
   bool fun_flag_inline;
   bool fun_flag_nothrow;
   bool fun_flag_really_nothrow;
   bool fun_flag_private;
   struct _fx_N17Ast__fun_constr_t fun_flag_ctor;
   struct _fx_R9Ast__id_t fun_flag_method_of;
   bool fun_flag_uses_fv;
   bool fun_flag_recursive;
   bool fun_flag_instance;
} _fx_R16Ast__fun_flags_t;

typedef struct _fx_Ta2R9Ast__id_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_R9Ast__id_t t1;
} _fx_Ta2R9Ast__id_t;

typedef struct _fx_LR9Ast__id_t_data_t {
   int_ rc;
   struct _fx_LR9Ast__id_t_data_t* tl;
   struct _fx_R9Ast__id_t hd;
} _fx_LR9Ast__id_t_data_t, *_fx_LR9Ast__id_t;

typedef struct _fx_R16Ast__var_flags_t {
   int_ var_flag_class_from;
   bool var_flag_record;
   bool var_flag_recursive;
   bool var_flag_have_tag;
   bool var_flag_have_mutable;
   bool var_flag_opt;
   bool var_flag_instance;
} _fx_R16Ast__var_flags_t;

typedef struct _fx_R16Ast__ast_callb_t {
   struct _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_data_t* ast_cb_typ;
   struct _fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t_data_t* ast_cb_exp;
   struct _fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t_data_t* ast_cb_pat;
} _fx_R16Ast__ast_callb_t;

typedef struct _fx_FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t {
   int (*fp)(struct _fx_N10Ast__pat_t_data_t*, struct _fx_R16Ast__ast_callb_t*, struct _fx_N10Ast__pat_t_data_t**, void*);
   fx_fcv_t* fcv;
} _fx_FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t;

typedef struct _fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t_data_t {
   int_ rc;
   union {
      struct _fx_FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t Some;
   } u;
} _fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t_data_t, *_fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t;

typedef struct _fx_FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t {
   int (*fp)(struct _fx_N10Ast__exp_t_data_t*, struct _fx_R16Ast__ast_callb_t*, struct _fx_N10Ast__exp_t_data_t**, void*);
   fx_fcv_t* fcv;
} _fx_FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t;

typedef struct _fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t_data_t {
   int_ rc;
   union {
      struct _fx_FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t Some;
   } u;
} _fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t_data_t, *_fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t;

typedef struct _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t {
   int (*fp)(struct _fx_N10Ast__typ_t_data_t*, struct _fx_R16Ast__ast_callb_t*, struct _fx_N10Ast__typ_t_data_t**, void*);
   fx_fcv_t* fcv;
} _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t;

typedef struct _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_data_t {
   int_ rc;
   union {
      struct _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t Some;
   } u;
} _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_data_t, *_fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t;

typedef struct _fx_Nt6option1R9Ast__id_t {
   int tag;
   union {
      struct _fx_R9Ast__id_t Some;
   } u;
} _fx_Nt6option1R9Ast__id_t;

typedef struct _fx_Nt6option1N10Ast__exp_t_data_t {
   int_ rc;
   union {
      struct _fx_N10Ast__exp_t_data_t* Some;
   } u;
} _fx_Nt6option1N10Ast__exp_t_data_t, *_fx_Nt6option1N10Ast__exp_t;

typedef struct _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t {
   uint64_t hv;
   struct _fx_R9Ast__id_t key;
} _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t;

typedef struct _fx_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t {
   struct _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t t0;
   int_ t1;
   int_ t2;
   int_ t3;
   fx_arr_t t4;
   fx_arr_t t5;
} _fx_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t;

typedef struct _fx_Nt10Hashset__t1R9Ast__id_t_data_t {
   int_ rc;
   union {
      struct _fx_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t t;
   } u;
} _fx_Nt10Hashset__t1R9Ast__id_t_data_t, *_fx_Nt10Hashset__t1R9Ast__id_t;

typedef struct _fx_R13Ast__defval_t {
   struct _fx_R9Ast__id_t dv_name;
   struct _fx_N10Ast__typ_t_data_t* dv_typ;
   struct _fx_R16Ast__val_flags_t dv_flags;
   struct _fx_LN12Ast__scope_t_data_t* dv_scope;
   struct _fx_R10Ast__loc_t dv_loc;
} _fx_R13Ast__defval_t;

typedef struct _fx_FPi2R9Ast__id_tR9Ast__id_t {
   int (*fp)(struct _fx_R9Ast__id_t*, struct _fx_R9Ast__id_t*, int_*, void*);
   fx_fcv_t* fcv;
} _fx_FPi2R9Ast__id_tR9Ast__id_t;

typedef struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t {
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* root;
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t cmp;
} _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t;

typedef struct _fx_LN10Ast__pat_t_data_t {
   int_ rc;
   struct _fx_LN10Ast__pat_t_data_t* tl;
   struct _fx_N10Ast__pat_t_data_t* hd;
} _fx_LN10Ast__pat_t_data_t, *_fx_LN10Ast__pat_t;

typedef struct _fx_rLR9Ast__id_t_data_t {
   int_ rc;
   struct _fx_LR9Ast__id_t_data_t* data;
} _fx_rLR9Ast__id_t_data_t, *_fx_rLR9Ast__id_t;

typedef struct _fx_R13Ast__deffun_t {
   struct _fx_R9Ast__id_t df_name;
   struct _fx_LR9Ast__id_t_data_t* df_templ_args;
   struct _fx_LN10Ast__pat_t_data_t* df_args;
   struct _fx_N10Ast__typ_t_data_t* df_typ;
   struct _fx_N10Ast__exp_t_data_t* df_body;
   struct _fx_R16Ast__fun_flags_t df_flags;
   struct _fx_LN12Ast__scope_t_data_t* df_scope;
   struct _fx_R10Ast__loc_t df_loc;
   struct _fx_rLR9Ast__id_t_data_t* df_templ_inst;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t df_env;
} _fx_R13Ast__deffun_t;

typedef struct _fx_rR13Ast__deffun_t_data_t {
   int_ rc;
   struct _fx_R13Ast__deffun_t data;
} _fx_rR13Ast__deffun_t_data_t, *_fx_rR13Ast__deffun_t;

typedef struct _fx_R13Ast__defexn_t {
   struct _fx_R9Ast__id_t dexn_name;
   struct _fx_N10Ast__typ_t_data_t* dexn_typ;
   struct _fx_LN12Ast__scope_t_data_t* dexn_scope;
   struct _fx_R10Ast__loc_t dexn_loc;
} _fx_R13Ast__defexn_t;

typedef struct _fx_rR13Ast__defexn_t_data_t {
   int_ rc;
   struct _fx_R13Ast__defexn_t data;
} _fx_rR13Ast__defexn_t_data_t, *_fx_rR13Ast__defexn_t;

typedef struct _fx_R13Ast__deftyp_t {
   struct _fx_R9Ast__id_t dt_name;
   struct _fx_LR9Ast__id_t_data_t* dt_templ_args;
   struct _fx_N10Ast__typ_t_data_t* dt_typ;
   bool dt_finalized;
   struct _fx_LN12Ast__scope_t_data_t* dt_scope;
   struct _fx_R10Ast__loc_t dt_loc;
} _fx_R13Ast__deftyp_t;

typedef struct _fx_rR13Ast__deftyp_t_data_t {
   int_ rc;
   struct _fx_R13Ast__deftyp_t data;
} _fx_rR13Ast__deftyp_t_data_t, *_fx_rR13Ast__deftyp_t;

typedef struct _fx_T2R9Ast__id_tN10Ast__typ_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_T2R9Ast__id_tN10Ast__typ_t;

typedef struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t {
   int_ rc;
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* tl;
   struct _fx_T2R9Ast__id_tN10Ast__typ_t hd;
} _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t, *_fx_LT2R9Ast__id_tN10Ast__typ_t;

typedef struct _fx_LTa2R9Ast__id_t_data_t {
   int_ rc;
   struct _fx_LTa2R9Ast__id_t_data_t* tl;
   struct _fx_Ta2R9Ast__id_t hd;
} _fx_LTa2R9Ast__id_t_data_t, *_fx_LTa2R9Ast__id_t;

typedef struct _fx_T2R9Ast__id_tLTa2R9Ast__id_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_LTa2R9Ast__id_t_data_t* t1;
} _fx_T2R9Ast__id_tLTa2R9Ast__id_t;

typedef struct _fx_LT2R9Ast__id_tLTa2R9Ast__id_t_data_t {
   int_ rc;
   struct _fx_LT2R9Ast__id_tLTa2R9Ast__id_t_data_t* tl;
   struct _fx_T2R9Ast__id_tLTa2R9Ast__id_t hd;
} _fx_LT2R9Ast__id_tLTa2R9Ast__id_t_data_t, *_fx_LT2R9Ast__id_tLTa2R9Ast__id_t;

typedef struct _fx_R17Ast__defvariant_t {
   struct _fx_R9Ast__id_t dvar_name;
   struct _fx_LR9Ast__id_t_data_t* dvar_templ_args;
   struct _fx_N10Ast__typ_t_data_t* dvar_alias;
   struct _fx_R16Ast__var_flags_t dvar_flags;
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* dvar_cases;
   struct _fx_LR9Ast__id_t_data_t* dvar_ctors;
   struct _fx_rLR9Ast__id_t_data_t* dvar_templ_inst;
   struct _fx_LT2R9Ast__id_tLTa2R9Ast__id_t_data_t* dvar_ifaces;
   struct _fx_LN12Ast__scope_t_data_t* dvar_scope;
   struct _fx_R10Ast__loc_t dvar_loc;
} _fx_R17Ast__defvariant_t;

typedef struct _fx_rR17Ast__defvariant_t_data_t {
   int_ rc;
   struct _fx_R17Ast__defvariant_t data;
} _fx_rR17Ast__defvariant_t_data_t, *_fx_rR17Ast__defvariant_t;

typedef struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
   struct _fx_R16Ast__fun_flags_t t2;
} _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t;

typedef struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t {
   int_ rc;
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* tl;
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t hd;
} _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t, *_fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t;

typedef struct _fx_R19Ast__definterface_t {
   struct _fx_R9Ast__id_t di_name;
   struct _fx_R9Ast__id_t di_base;
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* di_new_methods;
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* di_all_methods;
   struct _fx_LN12Ast__scope_t_data_t* di_scope;
   struct _fx_R10Ast__loc_t di_loc;
} _fx_R19Ast__definterface_t;

typedef struct _fx_rR19Ast__definterface_t_data_t {
   int_ rc;
   struct _fx_R19Ast__definterface_t data;
} _fx_rR19Ast__definterface_t_data_t, *_fx_rR19Ast__definterface_t;

typedef struct _fx_N14Ast__id_info_t {
   int tag;
   union {
      struct _fx_R13Ast__defval_t IdDVal;
      struct _fx_rR13Ast__deffun_t_data_t* IdFun;
      struct _fx_rR13Ast__defexn_t_data_t* IdExn;
      struct _fx_rR13Ast__deftyp_t_data_t* IdTyp;
      struct _fx_rR17Ast__defvariant_t_data_t* IdVariant;
      struct _fx_rR19Ast__definterface_t_data_t* IdInterface;
      int_ IdModule;
   } u;
} _fx_N14Ast__id_info_t;

typedef struct _fx_T3iA1N14Ast__id_info_tN14Ast__id_info_t {
   int_ t0;
   fx_arr_t t1;
   struct _fx_N14Ast__id_info_t t2;
} _fx_T3iA1N14Ast__id_info_tN14Ast__id_info_t;

typedef struct _fx_Nt9Dynvec__t1N14Ast__id_info_t_data_t {
   int_ rc;
   union {
      struct _fx_T3iA1N14Ast__id_info_tN14Ast__id_info_t t;
   } u;
} _fx_Nt9Dynvec__t1N14Ast__id_info_t_data_t, *_fx_Nt9Dynvec__t1N14Ast__id_info_t;

typedef struct _fx_N12Map__color_t {
   int tag;
} _fx_N12Map__color_t;

typedef struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t {
   struct _fx_N12Map__color_t t0;
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* t1;
   struct _fx_R9Ast__id_t t2;
   struct _fx_R9Ast__id_t t3;
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* t4;
} _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t;

typedef struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t {
   int_ rc;
   union {
      struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t
         Node;
   } u;
} _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t, *_fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t;

typedef struct _fx_LN16Ast__env_entry_t_data_t {
   int_ rc;
   struct _fx_LN16Ast__env_entry_t_data_t* tl;
   struct _fx_N16Ast__env_entry_t_data_t* hd;
} _fx_LN16Ast__env_entry_t_data_t, *_fx_LN16Ast__env_entry_t;

typedef struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t {
   struct _fx_N12Map__color_t t0;
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t1;
   struct _fx_R9Ast__id_t t2;
   struct _fx_LN16Ast__env_entry_t_data_t* t3;
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t4;
} _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t;

typedef struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t {
   int_ rc;
   union {
      struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t
         Node;
   } u;
} _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t, *_fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t;

typedef struct _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t {
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* root;
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t cmp;
} _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t;

typedef struct _fx_N12Set__color_t {
   int tag;
} _fx_N12Set__color_t;

typedef struct _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t {
   struct _fx_N12Set__color_t t0;
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t1;
   struct _fx_R9Ast__id_t t2;
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t3;
} _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t;

typedef struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t {
   int_ rc;
   union {
      struct _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t Node;
   } u;
} _fx_Nt11Set__tree_t1R9Ast__id_t_data_t, *_fx_Nt11Set__tree_t1R9Ast__id_t;

typedef struct _fx_Rt6Set__t1R9Ast__id_t {
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* root;
   int_ size;
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t cmp;
} _fx_Rt6Set__t1R9Ast__id_t;

typedef struct _fx_T2R10Ast__loc_tS {
   struct _fx_R10Ast__loc_t t0;
   fx_str_t t1;
} _fx_T2R10Ast__loc_tS;

typedef struct _fx_T2il {
   int_ t0;
   int64_t t1;
} _fx_T2il;

typedef struct _fx_T2iq {
   int_ t0;
   uint64_t t1;
} _fx_T2iq;

typedef struct _fx_T2id {
   int_ t0;
   double t1;
} _fx_T2id;

typedef struct _fx_N10Ast__lit_t {
   int tag;
   union {
      int64_t LitInt;
      struct _fx_T2il LitSInt;
      struct _fx_T2iq LitUInt;
      struct _fx_T2id LitFloat;
      fx_str_t LitString;
      char_ LitChar;
      bool LitBool;
   } u;
} _fx_N10Ast__lit_t;

typedef struct _fx_rNt6option1N10Ast__typ_t_data_t {
   int_ rc;
   struct _fx_Nt6option1N10Ast__typ_t_data_t* data;
} _fx_rNt6option1N10Ast__typ_t_data_t, *_fx_rNt6option1N10Ast__typ_t;

typedef struct _fx_LN10Ast__typ_t_data_t {
   int_ rc;
   struct _fx_LN10Ast__typ_t_data_t* tl;
   struct _fx_N10Ast__typ_t_data_t* hd;
} _fx_LN10Ast__typ_t_data_t, *_fx_LN10Ast__typ_t;

typedef struct _fx_T2LN10Ast__typ_tN10Ast__typ_t {
   struct _fx_LN10Ast__typ_t_data_t* t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_T2LN10Ast__typ_tN10Ast__typ_t;

typedef struct _fx_T2iN10Ast__typ_t {
   int_ t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_T2iN10Ast__typ_t;

typedef struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t {
   struct _fx_R16Ast__val_flags_t t0;
   struct _fx_R9Ast__id_t t1;
   struct _fx_N10Ast__typ_t_data_t* t2;
   struct _fx_N10Ast__exp_t_data_t* t3;
} _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t;

typedef struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t {
   int_ rc;
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* tl;
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t hd;
} _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t, *_fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t;

typedef struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB {
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* t0;
   bool t1;
} _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB;

typedef struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t {
   int_ rc;
   struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB data;
} _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t, *_fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB;

typedef struct _fx_T2LN10Ast__typ_tR9Ast__id_t {
   struct _fx_LN10Ast__typ_t_data_t* t0;
   struct _fx_R9Ast__id_t t1;
} _fx_T2LN10Ast__typ_tR9Ast__id_t;

typedef struct _fx_N10Ast__typ_t_data_t {
   int_ rc;
   int tag;
   union {
      struct _fx_rNt6option1N10Ast__typ_t_data_t* TypVar;
      struct _fx_Nt6option1N10Ast__typ_t_data_t* TypVarTuple;
      struct _fx_N10Ast__typ_t_data_t* TypVarArray;
      int_ TypSInt;
      int_ TypUInt;
      int_ TypFloat;
      struct _fx_T2LN10Ast__typ_tN10Ast__typ_t TypFun;
      struct _fx_N10Ast__typ_t_data_t* TypList;
      struct _fx_N10Ast__typ_t_data_t* TypVector;
      struct _fx_LN10Ast__typ_t_data_t* TypTuple;
      struct _fx_N10Ast__typ_t_data_t* TypRef;
      struct _fx_T2iN10Ast__typ_t TypArray;
      struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t* TypRecord;
      struct _fx_T2LN10Ast__typ_tR9Ast__id_t TypApp;
   } u;
} _fx_N10Ast__typ_t_data_t, *_fx_N10Ast__typ_t;

typedef struct _fx_N12Ast__cmpop_t {
   int tag;
} _fx_N12Ast__cmpop_t;

typedef struct _fx_N13Ast__binary_t_data_t {
   int_ rc;
   int tag;
   union {
      struct _fx_N12Ast__cmpop_t OpCmp;
      struct _fx_N12Ast__cmpop_t OpDotCmp;
      struct _fx_N13Ast__binary_t_data_t* OpAugBinary;
   } u;
} _fx_N13Ast__binary_t_data_t, *_fx_N13Ast__binary_t;

typedef struct _fx_N12Ast__unary_t {
   int tag;
} _fx_N12Ast__unary_t;

typedef struct _fx_N12Ast__sctyp_t {
   int tag;
} _fx_N12Ast__sctyp_t;

typedef struct _fx_N13Ast__intrin_t {
   int tag;
   union {
      struct _fx_R9Ast__id_t IntrinMath;
      struct _fx_N12Ast__sctyp_t IntrinSaturate;
   } u;
} _fx_N13Ast__intrin_t;

typedef struct _fx_N15Ast__for_make_t {
   int tag;
} _fx_N15Ast__for_make_t;

typedef struct _fx_R16Ast__for_flags_t {
   bool for_flag_parallel;
   struct _fx_N15Ast__for_make_t for_flag_make;
   bool for_flag_unzip;
   bool for_flag_fold;
   bool for_flag_nested;
} _fx_R16Ast__for_flags_t;

typedef struct _fx_N13Ast__border_t {
   int tag;
} _fx_N13Ast__border_t;

typedef struct _fx_N18Ast__interpolate_t {
   int tag;
} _fx_N18Ast__interpolate_t;

typedef struct _fx_T2BR10Ast__loc_t {
   bool t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2BR10Ast__loc_t;

typedef struct _fx_T2Nt6option1N10Ast__exp_tR10Ast__loc_t {
   struct _fx_Nt6option1N10Ast__exp_t_data_t* t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2Nt6option1N10Ast__exp_tR10Ast__loc_t;

typedef struct _fx_T2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__typ_t_data_t* t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_Nt6option1N10Ast__exp_t_data_t* t0;
   struct _fx_Nt6option1N10Ast__exp_t_data_t* t1;
   struct _fx_Nt6option1N10Ast__exp_t_data_t* t2;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t3;
} _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__lit_t t0;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t1;
} _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t1;
} _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N13Ast__binary_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
   struct _fx_N10Ast__exp_t_data_t* t2;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t3;
} _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N12Ast__unary_t t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t2;
} _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_LN10Ast__exp_t_data_t {
   int_ rc;
   struct _fx_LN10Ast__exp_t_data_t* tl;
   struct _fx_N10Ast__exp_t_data_t* hd;
} _fx_LN10Ast__exp_t_data_t, *_fx_LN10Ast__exp_t;

typedef struct _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N13Ast__intrin_t t0;
   struct _fx_LN10Ast__exp_t_data_t* t1;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t2;
} _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T2R9Ast__id_tN10Ast__exp_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
} _fx_T2R9Ast__id_tN10Ast__exp_t;

typedef struct _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_LN10Ast__exp_t_data_t* t0;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t1;
} _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_LLN10Ast__exp_t_data_t {
   int_ rc;
   struct _fx_LLN10Ast__exp_t_data_t* tl;
   struct _fx_LN10Ast__exp_t_data_t* hd;
} _fx_LLN10Ast__exp_t_data_t, *_fx_LLN10Ast__exp_t;

typedef struct _fx_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_LLN10Ast__exp_t_data_t* t0;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t1;
} _fx_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t {
   int_ rc;
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t* tl;
   struct _fx_T2R9Ast__id_tN10Ast__exp_t hd;
} _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t, *_fx_LT2R9Ast__id_tN10Ast__exp_t;

typedef struct _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t* t1;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t2;
} _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_LN10Ast__exp_t_data_t* t1;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t2;
} _fx_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_N13Ast__border_t t1;
   struct _fx_N18Ast__interpolate_t t2;
   struct _fx_LN10Ast__exp_t_data_t* t3;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t4;
} _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t2;
} _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T2N10Ast__exp_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2N10Ast__exp_tR10Ast__loc_t;

typedef struct _fx_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
   struct _fx_N10Ast__exp_t_data_t* t2;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t3;
} _fx_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T2N10Ast__pat_tN10Ast__exp_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
} _fx_T2N10Ast__pat_tN10Ast__exp_t;

typedef struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t {
   int_ rc;
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* tl;
   struct _fx_T2N10Ast__pat_tN10Ast__exp_t hd;
} _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t, *_fx_LT2N10Ast__pat_tN10Ast__exp_t;

typedef struct _fx_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t {
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t0;
   struct _fx_N10Ast__pat_t_data_t* t1;
   struct _fx_N10Ast__exp_t_data_t* t2;
   struct _fx_R16Ast__for_flags_t t3;
   struct _fx_R10Ast__loc_t t4;
} _fx_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t;

typedef struct _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t {
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t0;
   struct _fx_N10Ast__pat_t_data_t* t1;
} _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t;

typedef struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t {
   int_ rc;
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t* tl;
   struct _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t hd;
} _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t, *_fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t;

typedef struct _fx_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
   struct _fx_R16Ast__for_flags_t t2;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t3;
} _fx_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t1;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t2;
} _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t2;
} _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T2ST2N10Ast__typ_tR10Ast__loc_t {
   fx_str_t t0;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t1;
} _fx_T2ST2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T3SST2N10Ast__typ_tR10Ast__loc_t {
   fx_str_t t0;
   fx_str_t t1;
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t t2;
} _fx_T3SST2N10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
   struct _fx_R16Ast__val_flags_t t2;
   struct _fx_R10Ast__loc_t t3;
} _fx_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t;

typedef struct _fx_T2iR9Ast__id_t {
   int_ t0;
   struct _fx_R9Ast__id_t t1;
} _fx_T2iR9Ast__id_t;

typedef struct _fx_LT2iR9Ast__id_t_data_t {
   int_ rc;
   struct _fx_LT2iR9Ast__id_t_data_t* tl;
   struct _fx_T2iR9Ast__id_t hd;
} _fx_LT2iR9Ast__id_t_data_t, *_fx_LT2iR9Ast__id_t;

typedef struct _fx_T2LT2iR9Ast__id_tR10Ast__loc_t {
   struct _fx_LT2iR9Ast__id_t_data_t* t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2LT2iR9Ast__id_tR10Ast__loc_t;

typedef struct _fx_T3iLR9Ast__id_tR10Ast__loc_t {
   int_ t0;
   struct _fx_LR9Ast__id_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3iLR9Ast__id_tR10Ast__loc_t;

typedef struct _fx_T2LSR10Ast__loc_t {
   struct _fx_LS_data_t* t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2LSR10Ast__loc_t;

typedef struct _fx_N10Ast__exp_t_data_t {
   int_ rc;
   int tag;
   union {
      struct _fx_R10Ast__loc_t ExpNop;
      struct _fx_T2BR10Ast__loc_t ExpBreak;
      struct _fx_R10Ast__loc_t ExpContinue;
      struct _fx_T2Nt6option1N10Ast__exp_tR10Ast__loc_t ExpReturn;
      struct _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpRange;
      struct _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t ExpLit;
      struct _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t ExpIdent;
      struct _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpBinary;
      struct _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpUnary;
      struct _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpIntrin;
      struct _fx_T2R9Ast__id_tN10Ast__exp_t ExpSync;
      struct _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpSeq;
      struct _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpMkTuple;
      struct _fx_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpMkArray;
      struct _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpMkVector;
      struct _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpMkRecord;
      struct _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpUpdateRecord;
      struct _fx_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpCall;
      struct _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpAt;
      struct _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t ExpAssign;
      struct _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpMem;
      struct _fx_T2N10Ast__exp_tR10Ast__loc_t ExpThrow;
      struct _fx_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpIf;
      struct _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t ExpWhile;
      struct _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t ExpDoWhile;
      struct _fx_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t ExpFor;
      struct _fx_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t
         ExpMap;
      struct _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpTryCatch;
      struct _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t ExpMatch;
      struct _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t ExpCast;
      struct _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t ExpTyped;
      struct _fx_T2ST2N10Ast__typ_tR10Ast__loc_t ExpCCode;
      struct _fx_T3SST2N10Ast__typ_tR10Ast__loc_t ExpData;
      struct _fx_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t DefVal;
      struct _fx_rR13Ast__deffun_t_data_t* DefFun;
      struct _fx_rR13Ast__defexn_t_data_t* DefExn;
      struct _fx_rR13Ast__deftyp_t_data_t* DefTyp;
      struct _fx_rR17Ast__defvariant_t_data_t* DefVariant;
      struct _fx_rR19Ast__definterface_t_data_t* DefInterface;
      struct _fx_T2LT2iR9Ast__id_tR10Ast__loc_t DirImport;
      struct _fx_T3iLR9Ast__id_tR10Ast__loc_t DirImportFrom;
      struct _fx_T2LSR10Ast__loc_t DirPragma;
   } u;
} _fx_N10Ast__exp_t_data_t, *_fx_N10Ast__exp_t;

typedef struct _fx_T2N10Ast__lit_tR10Ast__loc_t {
   struct _fx_N10Ast__lit_t t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2N10Ast__lit_tR10Ast__loc_t;

typedef struct _fx_T2R9Ast__id_tR10Ast__loc_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2R9Ast__id_tR10Ast__loc_t;

typedef struct _fx_T2LN10Ast__pat_tR10Ast__loc_t {
   struct _fx_LN10Ast__pat_t_data_t* t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2LN10Ast__pat_tR10Ast__loc_t;

typedef struct _fx_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_LN10Ast__pat_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t;

typedef struct _fx_T2R9Ast__id_tN10Ast__pat_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_N10Ast__pat_t_data_t* t1;
} _fx_T2R9Ast__id_tN10Ast__pat_t;

typedef struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t {
   int_ rc;
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* tl;
   struct _fx_T2R9Ast__id_tN10Ast__pat_t hd;
} _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t, *_fx_LT2R9Ast__id_tN10Ast__pat_t;

typedef struct _fx_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t {
   struct _fx_Nt6option1R9Ast__id_t t0;
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_N10Ast__pat_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_R9Ast__id_t t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t;

typedef struct _fx_T2N10Ast__pat_tR10Ast__loc_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2N10Ast__pat_tR10Ast__loc_t;

typedef struct _fx_N10Ast__pat_t_data_t {
   int_ rc;
   int tag;
   union {
      struct _fx_R10Ast__loc_t PatAny;
      struct _fx_T2N10Ast__lit_tR10Ast__loc_t PatLit;
      struct _fx_T2R9Ast__id_tR10Ast__loc_t PatIdent;
      struct _fx_T2LN10Ast__pat_tR10Ast__loc_t PatTuple;
      struct _fx_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t PatVariant;
      struct _fx_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t PatRecord;
      struct _fx_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t PatCons;
      struct _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t PatAs;
      struct _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t PatTyped;
      struct _fx_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t PatWhen;
      struct _fx_T2LN10Ast__pat_tR10Ast__loc_t PatAlt;
      struct _fx_T2N10Ast__pat_tR10Ast__loc_t PatRef;
   } u;
} _fx_N10Ast__pat_t_data_t, *_fx_N10Ast__pat_t;

typedef struct _fx_N16Ast__env_entry_t_data_t {
   int_ rc;
   int tag;
   union {
      struct _fx_R9Ast__id_t EnvId;
      struct _fx_N10Ast__typ_t_data_t* EnvTyp;
   } u;
} _fx_N16Ast__env_entry_t_data_t, *_fx_N16Ast__env_entry_t;

typedef struct _fx_Li_data_t {
   int_ rc;
   struct _fx_Li_data_t* tl;
   int_ hd;
} _fx_Li_data_t, *_fx_Li;

typedef struct _fx_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t {
   struct _fx_R9Ast__id_t t0;
   fx_str_t t1;
   int_ t2;
   bool t3;
   struct _fx_LN10Ast__exp_t_data_t* t4;
   struct _fx_Li_data_t* t5;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t6;
   bool t7;
   int_ t8;
   struct _fx_Nt9Dynvec__t1N14Ast__id_info_t_data_t* t9;
} _fx_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t;

typedef struct _fx_N16Ast__defmodule_t_data_t {
   int_ rc;
   union {
      struct _fx_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t
         defmodule_t;
   } u;
} _fx_N16Ast__defmodule_t_data_t, *_fx_N16Ast__defmodule_t;

typedef struct _fx_LR10Ast__loc_t_data_t {
   int_ rc;
   struct _fx_LR10Ast__loc_t_data_t* tl;
   struct _fx_R10Ast__loc_t hd;
} _fx_LR10Ast__loc_t_data_t, *_fx_LR10Ast__loc_t;

typedef struct _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
} _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t_data_t {
   int_ rc;
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t_data_t* tl;
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t hd;
} _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t_data_t, *_fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_rB_data_t {
   int_ rc;
   bool data;
} _fx_rB_data_t, *_fx_rB;

typedef struct _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t {
   int tag;
   union {
      struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t Some;
   } u;
} _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t;

typedef struct _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t {
   int tag;
   union {
      struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t Some;
   } u;
} _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t;

typedef struct _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t {
   struct _fx_T2R9Ast__id_tN10Ast__typ_t t0;
   struct _fx_R9Ast__id_t t1;
} _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t;

typedef struct _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t {
   int tag;
   union {
      struct _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t Some;
   } u;
} _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t;

typedef struct _fx_Nt6option1N10Ast__lit_t {
   int tag;
   union {
      struct _fx_N10Ast__lit_t Some;
   } u;
} _fx_Nt6option1N10Ast__lit_t;

typedef struct _fx_Nt6option1LN16Ast__env_entry_t {
   int tag;
   union {
      struct _fx_LN16Ast__env_entry_t_data_t* Some;
   } u;
} _fx_Nt6option1LN16Ast__env_entry_t;

typedef struct _fx_rRt6Set__t1R9Ast__id_t_data_t {
   int_ rc;
   struct _fx_Rt6Set__t1R9Ast__id_t data;
} _fx_rRt6Set__t1R9Ast__id_t_data_t, *_fx_rRt6Set__t1R9Ast__id_t;

typedef struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t {
   int tag;
   union {
      struct _fx_rRt6Set__t1R9Ast__id_t_data_t* Some;
   } u;
} _fx_Nt6option1rRt6Set__t1R9Ast__id_t;

typedef struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t {
   int tag;
   union {
      struct _fx_T2R9Ast__id_tN10Ast__typ_t Some;
   } u;
} _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t;

typedef struct _fx_T2N10Ast__exp_tB {
   struct _fx_N10Ast__exp_t_data_t* t0;
   bool t1;
} _fx_T2N10Ast__exp_tB;

typedef struct _fx_LT2N10Ast__exp_tB_data_t {
   int_ rc;
   struct _fx_LT2N10Ast__exp_tB_data_t* tl;
   struct _fx_T2N10Ast__exp_tB hd;
} _fx_LT2N10Ast__exp_tB_data_t, *_fx_LT2N10Ast__exp_tB;

typedef struct _fx_FPN10Ast__typ_t1N10Ast__exp_t {
   int (*fp)(struct _fx_N10Ast__exp_t_data_t*, struct _fx_N10Ast__typ_t_data_t**, void*);
   fx_fcv_t* fcv;
} _fx_FPN10Ast__typ_t1N10Ast__exp_t;

typedef struct _fx_FPN10Ast__exp_t1N10Ast__exp_t {
   int (*fp)(struct _fx_N10Ast__exp_t_data_t*, struct _fx_N10Ast__exp_t_data_t**, void*);
   fx_fcv_t* fcv;
} _fx_FPN10Ast__exp_t1N10Ast__exp_t;

typedef struct _fx_FPB1N10Ast__typ_t {
   int (*fp)(struct _fx_N10Ast__typ_t_data_t*, bool*, void*);
   fx_fcv_t* fcv;
} _fx_FPB1N10Ast__typ_t;

typedef struct _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t {
   int (*fp)(struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t*, bool*, void*);
   fx_fcv_t* fcv;
} _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t;

typedef struct _fx_FPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t {
   int (*fp)(
      struct _fx_R9Ast__id_t*, struct _fx_LN16Ast__env_entry_t_data_t*, struct _fx_LR9Ast__id_t_data_t*,
         struct _fx_LR9Ast__id_t_data_t**, void*);
   fx_fcv_t* fcv;
} _fx_FPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t;

typedef struct _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t {
   int (*fp)(
      struct _fx_R9Ast__id_t*, struct _fx_LN16Ast__env_entry_t_data_t*, struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t*,
         struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t*, void*);
   fx_fcv_t* fcv;
} _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t;

typedef struct _fx_T2Nt11Set__tree_t1R9Ast__id_ti {
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t0;
   int_ t1;
} _fx_T2Nt11Set__tree_t1R9Ast__id_ti;

typedef struct _fx_T2Nt11Set__tree_t1R9Ast__id_tB {
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t0;
   bool t1;
} _fx_T2Nt11Set__tree_t1R9Ast__id_tB;

typedef struct _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t {
   struct _fx_rNt6option1N10Ast__typ_t_data_t* t0;
   struct _fx_Nt6option1N10Ast__typ_t_data_t* t1;
} _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t;

typedef struct _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t {
   int_ rc;
   struct _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* tl;
   struct _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t hd;
} _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t, *_fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t;

typedef struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t {
   int_ rc;
   struct _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* data;
} _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t, *_fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t;

typedef struct _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB {
   struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t* t0;
   struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB t1;
} _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB;

typedef struct _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t {
   int_ rc;
   struct _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      tl;
   struct _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB
      hd;
} _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t, *_fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB;

typedef struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t {
   int_ rc;
   struct _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      data;
} _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t, *_fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB;

typedef struct _fx_FPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t {
   int (*fp)(struct _fx_N10Ast__typ_t_data_t*, struct _fx_N10Ast__typ_t_data_t*, struct _fx_R10Ast__loc_t*, bool*, void*);
   fx_fcv_t* fcv;
} _fx_FPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t;

typedef struct _fx_FPB5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t {
   int (*fp)(
      struct _fx_LN10Ast__typ_t_data_t*, struct _fx_LN10Ast__typ_t_data_t*, struct _fx_R10Ast__loc_t*,
         struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*,
         struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t*, bool*, void*);
   fx_fcv_t* fcv;
} _fx_FPB5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t;

typedef struct _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB {
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t0;
   bool t1;
} _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB;

typedef struct _fx_FPv1N14Ast__id_info_t {
   int (*fp)(struct _fx_N14Ast__id_info_t*, void*);
   fx_fcv_t* fcv;
} _fx_FPv1N14Ast__id_info_t;

typedef struct _fx_Ta2l {
   int64_t t0;
   int64_t t1;
} _fx_Ta2l;

typedef struct _fx_T2N10Ast__exp_tN10Ast__typ_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_T2N10Ast__exp_tN10Ast__typ_t;

typedef struct _fx_T2LN10Ast__exp_tLN10Ast__typ_t {
   struct _fx_LN10Ast__exp_t_data_t* t0;
   struct _fx_LN10Ast__typ_t_data_t* t1;
} _fx_T2LN10Ast__exp_tLN10Ast__typ_t;

typedef struct _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t {
   struct _fx_R9Ast__id_t t0;
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* t1;
} _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t;

typedef struct _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t {
   int (*fp)(struct _fx_N16Ast__env_entry_t_data_t*, struct _fx_Nt6option1N10Ast__typ_t_data_t**, void*);
   fx_fcv_t* fcv;
} _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t;

typedef struct _fx_FPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t {
   int (*fp)(struct _fx_N16Ast__env_entry_t_data_t*, struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t*, void*);
   fx_fcv_t* fcv;
} _fx_FPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t;

typedef struct _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t {
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t t0;
   struct _fx_LN16Ast__env_entry_t_data_t* t1;
} _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t;

typedef struct _fx_rLN16Ast__env_entry_t_data_t {
   int_ rc;
   struct _fx_LN16Ast__env_entry_t_data_t* data;
} _fx_rLN16Ast__env_entry_t_data_t, *_fx_rLN16Ast__env_entry_t;

typedef struct _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t {
   struct _fx_N10Ast__typ_t_data_t* t0;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t1;
} _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t;

typedef struct _fx_Ta2N10Ast__exp_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_N10Ast__exp_t_data_t* t1;
} _fx_Ta2N10Ast__exp_t;

typedef struct _fx_T2N13Ast__binary_tNt6option1N10Ast__typ_t {
   struct _fx_N13Ast__binary_t_data_t* t0;
   struct _fx_Nt6option1N10Ast__typ_t_data_t* t1;
} _fx_T2N13Ast__binary_tNt6option1N10Ast__typ_t;

typedef struct _fx_Ta2N10Ast__typ_t {
   struct _fx_N10Ast__typ_t_data_t* t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_Ta2N10Ast__typ_t;

typedef struct _fx_T2N10Ast__exp_ti {
   struct _fx_N10Ast__exp_t_data_t* t0;
   int_ t1;
} _fx_T2N10Ast__exp_ti;

typedef struct _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t {
   struct _fx_LN10Ast__exp_t_data_t* t0;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t1;
} _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t;

typedef struct _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_N13Ast__border_t t1;
   struct _fx_N18Ast__interpolate_t t2;
} _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t;

typedef struct _fx_T4LN10Ast__exp_tiii {
   struct _fx_LN10Ast__exp_t_data_t* t0;
   int_ t1;
   int_ t2;
   int_ t3;
} _fx_T4LN10Ast__exp_tiii;

typedef struct _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t {
   int_ t0;
   struct _fx_LN10Ast__exp_t_data_t* t1;
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t2;
   struct _fx_N10Ast__pat_t_data_t* t3;
   int_ t4;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t5;
   struct _fx_Rt6Set__t1R9Ast__id_t t6;
} _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t;

typedef struct _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t {
   int_ t0;
   struct _fx_LN10Ast__exp_t_data_t* t1;
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t* t2;
   int_ t3;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t4;
   struct _fx_Rt6Set__t1R9Ast__id_t t5;
} _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t;

typedef struct _fx_T4iLLN10Ast__exp_tBi {
   int_ t0;
   struct _fx_LLN10Ast__exp_t_data_t* t1;
   bool t2;
   int_ t3;
} _fx_T4iLLN10Ast__exp_tBi;

typedef struct _fx_T3BiLN10Ast__exp_t {
   bool t0;
   int_ t1;
   struct _fx_LN10Ast__exp_t_data_t* t2;
} _fx_T3BiLN10Ast__exp_t;

typedef struct _fx_T3SiN10Ast__typ_t {
   fx_str_t t0;
   int_ t1;
   struct _fx_N10Ast__typ_t_data_t* t2;
} _fx_T3SiN10Ast__typ_t;

typedef struct _fx_T4BiN10Ast__exp_tR10Ast__loc_t {
   bool t0;
   int_ t1;
   struct _fx_N10Ast__exp_t_data_t* t2;
   struct _fx_R10Ast__loc_t t3;
} _fx_T4BiN10Ast__exp_tR10Ast__loc_t;

typedef struct _fx_T2SN10Ast__typ_t {
   fx_str_t t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_T2SN10Ast__typ_t;

typedef struct _fx_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t {
   struct _fx_T2R9Ast__id_tN10Ast__exp_t t0;
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t t1;
} _fx_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t;

typedef struct _fx_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t {
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t* t0;
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* t1;
} _fx_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t;

typedef struct _fx_T2N10Ast__exp_tLN10Ast__exp_t {
   struct _fx_N10Ast__exp_t_data_t* t0;
   struct _fx_LN10Ast__exp_t_data_t* t1;
} _fx_T2N10Ast__exp_tLN10Ast__exp_t;

typedef struct _fx_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t {
   int_ t0;
   struct _fx_T2N10Ast__pat_tN10Ast__exp_t t1;
   struct _fx_LN10Ast__exp_t_data_t* t2;
   int_ t3;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t4;
   struct _fx_Rt6Set__t1R9Ast__id_t t5;
} _fx_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t;

typedef struct _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t1;
   struct _fx_Rt6Set__t1R9Ast__id_t t2;
   struct _fx_Rt6Set__t1R9Ast__id_t t3;
   bool t4;
} _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB;

typedef struct _fx_T2N10Ast__typ_ti {
   struct _fx_N10Ast__typ_t_data_t* t0;
   int_ t1;
} _fx_T2N10Ast__typ_ti;

typedef struct _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t {
   int_ t0;
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t1;
   struct _fx_LN10Ast__exp_t_data_t* t2;
   int_ t3;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t4;
   struct _fx_Rt6Set__t1R9Ast__id_t t5;
} _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t;

typedef struct _fx_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t1;
   struct _fx_Rt6Set__t1R9Ast__id_t t2;
} _fx_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t;

typedef struct _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t {
   struct _fx_LN10Ast__exp_t_data_t* t0;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t1;
   struct _fx_Rt6Set__t1R9Ast__id_t t2;
} _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t;

typedef struct _fx_Ta2N10Ast__pat_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_N10Ast__pat_t_data_t* t1;
} _fx_Ta2N10Ast__pat_t;

typedef struct _fx_T2N10Ast__pat_tN10Ast__typ_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_T2N10Ast__pat_tN10Ast__typ_t;

typedef struct _fx_T2iR10Ast__loc_t {
   int_ t0;
   struct _fx_R10Ast__loc_t t1;
} _fx_T2iR10Ast__loc_t;

typedef struct _fx_LT2iR10Ast__loc_t_data_t {
   int_ rc;
   struct _fx_LT2iR10Ast__loc_t_data_t* tl;
   struct _fx_T2iR10Ast__loc_t hd;
} _fx_LT2iR10Ast__loc_t_data_t, *_fx_LT2iR10Ast__loc_t;

typedef struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t {
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t0;
   struct _fx_LT2iR10Ast__loc_t_data_t* t1;
} _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t;

typedef struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t {
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t0;
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* t1;
} _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t;

typedef struct _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB {
   struct _fx_LN10Ast__pat_t_data_t* t0;
   struct _fx_LN10Ast__typ_t_data_t* t1;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t2;
   struct _fx_Rt6Set__t1R9Ast__id_t t3;
   struct _fx_Rt6Set__t1R9Ast__id_t t4;
   bool t5;
} _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB;

typedef struct _fx_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t {
   struct _fx_N10Ast__pat_t_data_t* t0;
   struct _fx_Rt6Set__t1R9Ast__id_t t1;
} _fx_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t;

typedef struct _fx_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB {
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* t0;
   bool t1;
} _fx_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB;

typedef struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t {
   int_ rc;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t data;
} _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t, *_fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t;

typedef struct _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t {
   struct _fx_LN10Ast__pat_t_data_t* t0;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t1;
   struct _fx_Rt6Set__t1R9Ast__id_t t2;
} _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t;

typedef struct _fx_T2rR17Ast__defvariant_tN10Ast__typ_t {
   struct _fx_rR17Ast__defvariant_t_data_t* t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_T2rR17Ast__defvariant_tN10Ast__typ_t;

typedef struct _fx_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t {
   struct _fx_LR9Ast__id_t_data_t* t0;
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* t1;
} _fx_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t;

typedef struct _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t {
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* t0;
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* t1;
   struct _fx_N10Ast__exp_t_data_t* t2;
} _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t;

typedef struct _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t {
   struct _fx_LN10Ast__pat_t_data_t* t0;
   struct _fx_LN10Ast__pat_t_data_t* t1;
   struct _fx_N10Ast__exp_t_data_t* t2;
} _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t;

typedef struct _fx_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t {
   bool t0;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t1;
   struct _fx_R9Ast__id_t t2;
   struct _fx_N10Ast__typ_t_data_t* t3;
   struct _fx_rR17Ast__defvariant_t_data_t* t4;
} _fx_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t;

typedef struct _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t {
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* t0;
   struct _fx_LR9Ast__id_t_data_t* t1;
} _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t;

typedef struct _fx_T2N10Ast__pat_tB {
   struct _fx_N10Ast__pat_t_data_t* t0;
   bool t1;
} _fx_T2N10Ast__pat_tB;

typedef struct {
   int_ rc;
   int_ data;
} _fx_E4Exit_data_t;

typedef struct {
   int_ rc;
   fx_str_t data;
} _fx_E4Fail_data_t;

typedef struct {
   int_ rc;
   struct _fx_T2Ta2iS data;
} _fx_E22LexerUtils__LexerError_data_t;

typedef struct {
   int_ rc;
   struct _fx_T2R10Ast__loc_tS data;
} _fx_E17Ast__CompileError_data_t;

typedef struct {
   int_ rc;
   struct _fx_T2R10Ast__loc_tS data;
} _fx_E18Parser__ParseError_data_t;

static void _fx_free_Nt6option1N10Ast__typ_t(struct _fx_Nt6option1N10Ast__typ_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      _fx_free_N10Ast__typ_t(&(*dst)->u.Some); fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_LS(struct _fx_LS_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LS, fx_free_str);
}

static int _fx_cons_LS(fx_str_t* hd, struct _fx_LS_data_t* tl, bool addref_tl, struct _fx_LS_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LS, fx_copy_str);
}

static void _fx_free_N17Options__optval_t(struct _fx_N17Options__optval_t* dst)
{
   switch (dst->tag) {
   case 3:
      fx_free_str(&dst->u.OptString); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_N17Options__optval_t(struct _fx_N17Options__optval_t* src, struct _fx_N17Options__optval_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 3:
      fx_copy_str(&src->u.OptString, &dst->u.OptString); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_T2SN17Options__optval_t(struct _fx_T2SN17Options__optval_t* dst)
{
   fx_free_str(&dst->t0);
   _fx_free_N17Options__optval_t(&dst->t1);
}

static void _fx_copy_T2SN17Options__optval_t(struct _fx_T2SN17Options__optval_t* src, struct _fx_T2SN17Options__optval_t* dst)
{
   fx_copy_str(&src->t0, &dst->t0);
   _fx_copy_N17Options__optval_t(&src->t1, &dst->t1);
}

static void _fx_make_T2SN17Options__optval_t(
   fx_str_t* t0,
   struct _fx_N17Options__optval_t* t1,
   struct _fx_T2SN17Options__optval_t* fx_result)
{
   fx_copy_str(t0, &fx_result->t0);
   _fx_copy_N17Options__optval_t(t1, &fx_result->t1);
}

static void _fx_free_LT2SN17Options__optval_t(struct _fx_LT2SN17Options__optval_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2SN17Options__optval_t, _fx_free_T2SN17Options__optval_t);
}

static int _fx_cons_LT2SN17Options__optval_t(
   struct _fx_T2SN17Options__optval_t* hd,
   struct _fx_LT2SN17Options__optval_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2SN17Options__optval_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2SN17Options__optval_t, _fx_copy_T2SN17Options__optval_t);
}

static void _fx_free_R18Options__options_t(struct _fx_R18Options__options_t* dst)
{
   _fx_free_LS(&dst->app_args);
   fx_free_str(&dst->app_filename);
   fx_free_str(&dst->build_dir);
   fx_free_str(&dst->build_rootdir);
   fx_free_str(&dst->cflags);
   fx_free_str(&dst->clibs);
   fx_free_str(&dst->filename);
   _fx_free_LS(&dst->include_path);
   _fx_free_LT2SN17Options__optval_t(&dst->defines);
   fx_free_str(&dst->output_name);
}

static void _fx_copy_R18Options__options_t(struct _fx_R18Options__options_t* src, struct _fx_R18Options__options_t* dst)
{
   FX_COPY_PTR(src->app_args, &dst->app_args);
   fx_copy_str(&src->app_filename, &dst->app_filename);
   dst->arch64 = src->arch64;
   dst->force_rebuild = src->force_rebuild;
   fx_copy_str(&src->build_dir, &dst->build_dir);
   fx_copy_str(&src->build_rootdir, &dst->build_rootdir);
   fx_copy_str(&src->cflags, &dst->cflags);
   fx_copy_str(&src->clibs, &dst->clibs);
   dst->compile_by_cpp = src->compile_by_cpp;
   fx_copy_str(&src->filename, &dst->filename);
   dst->gen_c = src->gen_c;
   FX_COPY_PTR(src->include_path, &dst->include_path);
   dst->debug = src->debug;
   FX_COPY_PTR(src->defines, &dst->defines);
   dst->optim_iters = src->optim_iters;
   dst->inline_thresh = src->inline_thresh;
   dst->enable_openmp = src->enable_openmp;
   dst->relax = src->relax;
   dst->use_preamble = src->use_preamble;
   dst->make_app = src->make_app;
   dst->optimize_level = src->optimize_level;
   fx_copy_str(&src->output_name, &dst->output_name);
   dst->print_ast0 = src->print_ast0;
   dst->print_ast = src->print_ast;
   dst->print_k0 = src->print_k0;
   dst->print_k = src->print_k;
   dst->print_tokens = src->print_tokens;
   dst->run_app = src->run_app;
   dst->verbose = src->verbose;
   dst->W_unused = src->W_unused;
}

static void _fx_make_R18Options__options_t(
   struct _fx_LS_data_t* r_app_args,
   fx_str_t* r_app_filename,
   bool r_arch64,
   bool r_force_rebuild,
   fx_str_t* r_build_dir,
   fx_str_t* r_build_rootdir,
   fx_str_t* r_cflags,
   fx_str_t* r_clibs,
   bool r_compile_by_cpp,
   fx_str_t* r_filename,
   bool r_gen_c,
   struct _fx_LS_data_t* r_include_path,
   bool r_debug,
   struct _fx_LT2SN17Options__optval_t_data_t* r_defines,
   int_ r_optim_iters,
   int_ r_inline_thresh,
   bool r_enable_openmp,
   bool r_relax,
   bool r_use_preamble,
   bool r_make_app,
   int_ r_optimize_level,
   fx_str_t* r_output_name,
   bool r_print_ast0,
   bool r_print_ast,
   bool r_print_k0,
   bool r_print_k,
   bool r_print_tokens,
   bool r_run_app,
   bool r_verbose,
   bool r_W_unused,
   struct _fx_R18Options__options_t* fx_result)
{
   FX_COPY_PTR(r_app_args, &fx_result->app_args);
   fx_copy_str(r_app_filename, &fx_result->app_filename);
   fx_result->arch64 = r_arch64;
   fx_result->force_rebuild = r_force_rebuild;
   fx_copy_str(r_build_dir, &fx_result->build_dir);
   fx_copy_str(r_build_rootdir, &fx_result->build_rootdir);
   fx_copy_str(r_cflags, &fx_result->cflags);
   fx_copy_str(r_clibs, &fx_result->clibs);
   fx_result->compile_by_cpp = r_compile_by_cpp;
   fx_copy_str(r_filename, &fx_result->filename);
   fx_result->gen_c = r_gen_c;
   FX_COPY_PTR(r_include_path, &fx_result->include_path);
   fx_result->debug = r_debug;
   FX_COPY_PTR(r_defines, &fx_result->defines);
   fx_result->optim_iters = r_optim_iters;
   fx_result->inline_thresh = r_inline_thresh;
   fx_result->enable_openmp = r_enable_openmp;
   fx_result->relax = r_relax;
   fx_result->use_preamble = r_use_preamble;
   fx_result->make_app = r_make_app;
   fx_result->optimize_level = r_optimize_level;
   fx_copy_str(r_output_name, &fx_result->output_name);
   fx_result->print_ast0 = r_print_ast0;
   fx_result->print_ast = r_print_ast;
   fx_result->print_k0 = r_print_k0;
   fx_result->print_k = r_print_k;
   fx_result->print_tokens = r_print_tokens;
   fx_result->run_app = r_run_app;
   fx_result->verbose = r_verbose;
   fx_result->W_unused = r_W_unused;
}

static void _fx_free_T2Ta2iS(struct _fx_T2Ta2iS* dst)
{
   fx_free_str(&dst->t1);
}

static void _fx_copy_T2Ta2iS(struct _fx_T2Ta2iS* src, struct _fx_T2Ta2iS* dst)
{
   dst->t0 = src->t0;
   fx_copy_str(&src->t1, &dst->t1);
}

static void _fx_make_T2Ta2iS(struct _fx_Ta2i* t0, fx_str_t* t1, struct _fx_T2Ta2iS* fx_result)
{
   fx_result->t0 = *t0;
   fx_copy_str(t1, &fx_result->t1);
}

static int _fx_cons_LN12Ast__scope_t(
   struct _fx_N12Ast__scope_t* hd,
   struct _fx_LN12Ast__scope_t_data_t* tl,
   bool addref_tl,
   struct _fx_LN12Ast__scope_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LN12Ast__scope_t, FX_COPY_SIMPLE_BY_PTR);
}

static void _fx_free_R16Ast__val_flags_t(struct _fx_R16Ast__val_flags_t* dst)
{
   fx_free_list_simple(&dst->val_flag_global);
}

static void _fx_copy_R16Ast__val_flags_t(struct _fx_R16Ast__val_flags_t* src, struct _fx_R16Ast__val_flags_t* dst)
{
   dst->val_flag_arg = src->val_flag_arg;
   dst->val_flag_mutable = src->val_flag_mutable;
   dst->val_flag_temp = src->val_flag_temp;
   dst->val_flag_tempref = src->val_flag_tempref;
   dst->val_flag_private = src->val_flag_private;
   dst->val_flag_subarray = src->val_flag_subarray;
   dst->val_flag_instance = src->val_flag_instance;
   dst->val_flag_method = src->val_flag_method;
   dst->val_flag_ctor = src->val_flag_ctor;
   FX_COPY_PTR(src->val_flag_global, &dst->val_flag_global);
}

static void _fx_make_R16Ast__val_flags_t(
   bool r_val_flag_arg,
   bool r_val_flag_mutable,
   bool r_val_flag_temp,
   bool r_val_flag_tempref,
   bool r_val_flag_private,
   bool r_val_flag_subarray,
   bool r_val_flag_instance,
   struct _fx_T2R9Ast__id_ti* r_val_flag_method,
   int_ r_val_flag_ctor,
   struct _fx_LN12Ast__scope_t_data_t* r_val_flag_global,
   struct _fx_R16Ast__val_flags_t* fx_result)
{
   fx_result->val_flag_arg = r_val_flag_arg;
   fx_result->val_flag_mutable = r_val_flag_mutable;
   fx_result->val_flag_temp = r_val_flag_temp;
   fx_result->val_flag_tempref = r_val_flag_tempref;
   fx_result->val_flag_private = r_val_flag_private;
   fx_result->val_flag_subarray = r_val_flag_subarray;
   fx_result->val_flag_instance = r_val_flag_instance;
   fx_result->val_flag_method = *r_val_flag_method;
   fx_result->val_flag_ctor = r_val_flag_ctor;
   FX_COPY_PTR(r_val_flag_global, &fx_result->val_flag_global);
}

static int _fx_cons_LR9Ast__id_t(
   struct _fx_R9Ast__id_t* hd,
   struct _fx_LR9Ast__id_t_data_t* tl,
   bool addref_tl,
   struct _fx_LR9Ast__id_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LR9Ast__id_t, FX_COPY_SIMPLE_BY_PTR);
}

static void _fx_free_R16Ast__ast_callb_t(struct _fx_R16Ast__ast_callb_t* dst)
{
   _fx_free_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(&dst->ast_cb_typ);
   _fx_free_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t(&dst->ast_cb_exp);
   _fx_free_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t(&dst->ast_cb_pat);
}

static void _fx_copy_R16Ast__ast_callb_t(struct _fx_R16Ast__ast_callb_t* src, struct _fx_R16Ast__ast_callb_t* dst)
{
   FX_COPY_PTR(src->ast_cb_typ, &dst->ast_cb_typ);
   FX_COPY_PTR(src->ast_cb_exp, &dst->ast_cb_exp);
   FX_COPY_PTR(src->ast_cb_pat, &dst->ast_cb_pat);
}

static void _fx_make_R16Ast__ast_callb_t(
   struct _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_data_t* r_ast_cb_typ,
   struct _fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t_data_t* r_ast_cb_exp,
   struct _fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t_data_t* r_ast_cb_pat,
   struct _fx_R16Ast__ast_callb_t* fx_result)
{
   FX_COPY_PTR(r_ast_cb_typ, &fx_result->ast_cb_typ);
   FX_COPY_PTR(r_ast_cb_exp, &fx_result->ast_cb_exp);
   FX_COPY_PTR(r_ast_cb_pat, &fx_result->ast_cb_pat);
}

static void _fx_free_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t(
   struct _fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      fx_free_fp(&(*dst)->u.Some); fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t(
   struct _fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      fx_free_fp(&(*dst)->u.Some); fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   struct _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      fx_free_fp(&(*dst)->u.Some); fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_Nt6option1N10Ast__exp_t(struct _fx_Nt6option1N10Ast__exp_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      _fx_free_N10Ast__exp_t(&(*dst)->u.Some); fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t(
   struct _fx_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t* dst)
{
   fx_free_arr(&dst->t4);
   fx_free_arr(&dst->t5);
}

static void _fx_copy_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t(
   struct _fx_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t* src,
   struct _fx_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t* dst)
{
   dst->t0 = src->t0;
   dst->t1 = src->t1;
   dst->t2 = src->t2;
   dst->t3 = src->t3;
   fx_copy_arr(&src->t4, &dst->t4);
   fx_copy_arr(&src->t5, &dst->t5);
}

static void _fx_make_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t(
   struct _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t* t0,
   int_ t1,
   int_ t2,
   int_ t3,
   fx_arr_t* t4,
   fx_arr_t* t5,
   struct _fx_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t* fx_result)
{
   fx_result->t0 = *t0;
   fx_result->t1 = t1;
   fx_result->t2 = t2;
   fx_result->t3 = t3;
   fx_copy_arr(t4, &fx_result->t4);
   fx_copy_arr(t5, &fx_result->t5);
}

static void _fx_free_Nt10Hashset__t1R9Ast__id_t(struct _fx_Nt10Hashset__t1R9Ast__id_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      _fx_free_T6Rt24Hashset__hashset_entry_t1R9Ast__id_tiiiA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_t(&(*dst)->u.t);
      fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_R13Ast__defval_t(struct _fx_R13Ast__defval_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->dv_typ);
   _fx_free_R16Ast__val_flags_t(&dst->dv_flags);
   fx_free_list_simple(&dst->dv_scope);
}

static void _fx_copy_R13Ast__defval_t(struct _fx_R13Ast__defval_t* src, struct _fx_R13Ast__defval_t* dst)
{
   dst->dv_name = src->dv_name;
   FX_COPY_PTR(src->dv_typ, &dst->dv_typ);
   _fx_copy_R16Ast__val_flags_t(&src->dv_flags, &dst->dv_flags);
   FX_COPY_PTR(src->dv_scope, &dst->dv_scope);
   dst->dv_loc = src->dv_loc;
}

static void _fx_make_R13Ast__defval_t(
   struct _fx_R9Ast__id_t* r_dv_name,
   struct _fx_N10Ast__typ_t_data_t* r_dv_typ,
   struct _fx_R16Ast__val_flags_t* r_dv_flags,
   struct _fx_LN12Ast__scope_t_data_t* r_dv_scope,
   struct _fx_R10Ast__loc_t* r_dv_loc,
   struct _fx_R13Ast__defval_t* fx_result)
{
   fx_result->dv_name = *r_dv_name;
   FX_COPY_PTR(r_dv_typ, &fx_result->dv_typ);
   _fx_copy_R16Ast__val_flags_t(r_dv_flags, &fx_result->dv_flags);
   FX_COPY_PTR(r_dv_scope, &fx_result->dv_scope);
   fx_result->dv_loc = *r_dv_loc;
}

static void _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* dst)
{
   _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&dst->root);
   fx_free_fp(&dst->cmp);
}

static void _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* src,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* dst)
{
   FX_COPY_PTR(src->root, &dst->root);
   FX_COPY_FP(&src->cmp, &dst->cmp);
}

static void _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* r_root,
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t* r_cmp,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result)
{
   FX_COPY_PTR(r_root, &fx_result->root);
   FX_COPY_FP(r_cmp, &fx_result->cmp);
}

static void _fx_free_LN10Ast__pat_t(struct _fx_LN10Ast__pat_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LN10Ast__pat_t, _fx_free_N10Ast__pat_t);
}

static int _fx_cons_LN10Ast__pat_t(
   struct _fx_N10Ast__pat_t_data_t* hd,
   struct _fx_LN10Ast__pat_t_data_t* tl,
   bool addref_tl,
   struct _fx_LN10Ast__pat_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LN10Ast__pat_t, FX_COPY_PTR);
}

static void _fx_free_rLR9Ast__id_t(struct _fx_rLR9Ast__id_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rLR9Ast__id_t, fx_free_list_simple);
}

static int _fx_make_rLR9Ast__id_t(struct _fx_LR9Ast__id_t_data_t* arg, struct _fx_rLR9Ast__id_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rLR9Ast__id_t, FX_COPY_PTR);
}

static void _fx_free_R13Ast__deffun_t(struct _fx_R13Ast__deffun_t* dst)
{
   fx_free_list_simple(&dst->df_templ_args);
   _fx_free_LN10Ast__pat_t(&dst->df_args);
   _fx_free_N10Ast__typ_t(&dst->df_typ);
   _fx_free_N10Ast__exp_t(&dst->df_body);
   fx_free_list_simple(&dst->df_scope);
   _fx_free_rLR9Ast__id_t(&dst->df_templ_inst);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->df_env);
}

static void _fx_copy_R13Ast__deffun_t(struct _fx_R13Ast__deffun_t* src, struct _fx_R13Ast__deffun_t* dst)
{
   dst->df_name = src->df_name;
   FX_COPY_PTR(src->df_templ_args, &dst->df_templ_args);
   FX_COPY_PTR(src->df_args, &dst->df_args);
   FX_COPY_PTR(src->df_typ, &dst->df_typ);
   FX_COPY_PTR(src->df_body, &dst->df_body);
   dst->df_flags = src->df_flags;
   FX_COPY_PTR(src->df_scope, &dst->df_scope);
   dst->df_loc = src->df_loc;
   FX_COPY_PTR(src->df_templ_inst, &dst->df_templ_inst);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->df_env, &dst->df_env);
}

static void _fx_make_R13Ast__deffun_t(
   struct _fx_R9Ast__id_t* r_df_name,
   struct _fx_LR9Ast__id_t_data_t* r_df_templ_args,
   struct _fx_LN10Ast__pat_t_data_t* r_df_args,
   struct _fx_N10Ast__typ_t_data_t* r_df_typ,
   struct _fx_N10Ast__exp_t_data_t* r_df_body,
   struct _fx_R16Ast__fun_flags_t* r_df_flags,
   struct _fx_LN12Ast__scope_t_data_t* r_df_scope,
   struct _fx_R10Ast__loc_t* r_df_loc,
   struct _fx_rLR9Ast__id_t_data_t* r_df_templ_inst,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* r_df_env,
   struct _fx_R13Ast__deffun_t* fx_result)
{
   fx_result->df_name = *r_df_name;
   FX_COPY_PTR(r_df_templ_args, &fx_result->df_templ_args);
   FX_COPY_PTR(r_df_args, &fx_result->df_args);
   FX_COPY_PTR(r_df_typ, &fx_result->df_typ);
   FX_COPY_PTR(r_df_body, &fx_result->df_body);
   fx_result->df_flags = *r_df_flags;
   FX_COPY_PTR(r_df_scope, &fx_result->df_scope);
   fx_result->df_loc = *r_df_loc;
   FX_COPY_PTR(r_df_templ_inst, &fx_result->df_templ_inst);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(r_df_env, &fx_result->df_env);
}

static void _fx_free_rR13Ast__deffun_t(struct _fx_rR13Ast__deffun_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rR13Ast__deffun_t, _fx_free_R13Ast__deffun_t);
}

static int _fx_make_rR13Ast__deffun_t(struct _fx_R13Ast__deffun_t* arg, struct _fx_rR13Ast__deffun_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rR13Ast__deffun_t, _fx_copy_R13Ast__deffun_t);
}

static void _fx_free_R13Ast__defexn_t(struct _fx_R13Ast__defexn_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->dexn_typ);
   fx_free_list_simple(&dst->dexn_scope);
}

static void _fx_copy_R13Ast__defexn_t(struct _fx_R13Ast__defexn_t* src, struct _fx_R13Ast__defexn_t* dst)
{
   dst->dexn_name = src->dexn_name;
   FX_COPY_PTR(src->dexn_typ, &dst->dexn_typ);
   FX_COPY_PTR(src->dexn_scope, &dst->dexn_scope);
   dst->dexn_loc = src->dexn_loc;
}

static void _fx_make_R13Ast__defexn_t(
   struct _fx_R9Ast__id_t* r_dexn_name,
   struct _fx_N10Ast__typ_t_data_t* r_dexn_typ,
   struct _fx_LN12Ast__scope_t_data_t* r_dexn_scope,
   struct _fx_R10Ast__loc_t* r_dexn_loc,
   struct _fx_R13Ast__defexn_t* fx_result)
{
   fx_result->dexn_name = *r_dexn_name;
   FX_COPY_PTR(r_dexn_typ, &fx_result->dexn_typ);
   FX_COPY_PTR(r_dexn_scope, &fx_result->dexn_scope);
   fx_result->dexn_loc = *r_dexn_loc;
}

static void _fx_free_rR13Ast__defexn_t(struct _fx_rR13Ast__defexn_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rR13Ast__defexn_t, _fx_free_R13Ast__defexn_t);
}

static int _fx_make_rR13Ast__defexn_t(struct _fx_R13Ast__defexn_t* arg, struct _fx_rR13Ast__defexn_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rR13Ast__defexn_t, _fx_copy_R13Ast__defexn_t);
}

static void _fx_free_R13Ast__deftyp_t(struct _fx_R13Ast__deftyp_t* dst)
{
   fx_free_list_simple(&dst->dt_templ_args);
   _fx_free_N10Ast__typ_t(&dst->dt_typ);
   fx_free_list_simple(&dst->dt_scope);
}

static void _fx_copy_R13Ast__deftyp_t(struct _fx_R13Ast__deftyp_t* src, struct _fx_R13Ast__deftyp_t* dst)
{
   dst->dt_name = src->dt_name;
   FX_COPY_PTR(src->dt_templ_args, &dst->dt_templ_args);
   FX_COPY_PTR(src->dt_typ, &dst->dt_typ);
   dst->dt_finalized = src->dt_finalized;
   FX_COPY_PTR(src->dt_scope, &dst->dt_scope);
   dst->dt_loc = src->dt_loc;
}

static void _fx_make_R13Ast__deftyp_t(
   struct _fx_R9Ast__id_t* r_dt_name,
   struct _fx_LR9Ast__id_t_data_t* r_dt_templ_args,
   struct _fx_N10Ast__typ_t_data_t* r_dt_typ,
   bool r_dt_finalized,
   struct _fx_LN12Ast__scope_t_data_t* r_dt_scope,
   struct _fx_R10Ast__loc_t* r_dt_loc,
   struct _fx_R13Ast__deftyp_t* fx_result)
{
   fx_result->dt_name = *r_dt_name;
   FX_COPY_PTR(r_dt_templ_args, &fx_result->dt_templ_args);
   FX_COPY_PTR(r_dt_typ, &fx_result->dt_typ);
   fx_result->dt_finalized = r_dt_finalized;
   FX_COPY_PTR(r_dt_scope, &fx_result->dt_scope);
   fx_result->dt_loc = *r_dt_loc;
}

static void _fx_free_rR13Ast__deftyp_t(struct _fx_rR13Ast__deftyp_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rR13Ast__deftyp_t, _fx_free_R13Ast__deftyp_t);
}

static int _fx_make_rR13Ast__deftyp_t(struct _fx_R13Ast__deftyp_t* arg, struct _fx_rR13Ast__deftyp_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rR13Ast__deftyp_t, _fx_copy_R13Ast__deftyp_t);
}

static void _fx_free_T2R9Ast__id_tN10Ast__typ_t(struct _fx_T2R9Ast__id_tN10Ast__typ_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2R9Ast__id_tN10Ast__typ_t(
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* src,
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2R9Ast__id_tN10Ast__typ_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_LT2R9Ast__id_tN10Ast__typ_t(struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2R9Ast__id_tN10Ast__typ_t, _fx_free_T2R9Ast__id_tN10Ast__typ_t);
}

static int _fx_cons_LT2R9Ast__id_tN10Ast__typ_t(
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* hd,
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2R9Ast__id_tN10Ast__typ_t, _fx_copy_T2R9Ast__id_tN10Ast__typ_t);
}

static int _fx_cons_LTa2R9Ast__id_t(
   struct _fx_Ta2R9Ast__id_t* hd,
   struct _fx_LTa2R9Ast__id_t_data_t* tl,
   bool addref_tl,
   struct _fx_LTa2R9Ast__id_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LTa2R9Ast__id_t, FX_COPY_SIMPLE_BY_PTR);
}

static void _fx_free_T2R9Ast__id_tLTa2R9Ast__id_t(struct _fx_T2R9Ast__id_tLTa2R9Ast__id_t* dst)
{
   fx_free_list_simple(&dst->t1);
}

static void _fx_copy_T2R9Ast__id_tLTa2R9Ast__id_t(
   struct _fx_T2R9Ast__id_tLTa2R9Ast__id_t* src,
   struct _fx_T2R9Ast__id_tLTa2R9Ast__id_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2R9Ast__id_tLTa2R9Ast__id_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_LTa2R9Ast__id_t_data_t* t1,
   struct _fx_T2R9Ast__id_tLTa2R9Ast__id_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(struct _fx_LT2R9Ast__id_tLTa2R9Ast__id_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2R9Ast__id_tLTa2R9Ast__id_t, _fx_free_T2R9Ast__id_tLTa2R9Ast__id_t);
}

static int _fx_cons_LT2R9Ast__id_tLTa2R9Ast__id_t(
   struct _fx_T2R9Ast__id_tLTa2R9Ast__id_t* hd,
   struct _fx_LT2R9Ast__id_tLTa2R9Ast__id_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2R9Ast__id_tLTa2R9Ast__id_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2R9Ast__id_tLTa2R9Ast__id_t, _fx_copy_T2R9Ast__id_tLTa2R9Ast__id_t);
}

static void _fx_free_R17Ast__defvariant_t(struct _fx_R17Ast__defvariant_t* dst)
{
   fx_free_list_simple(&dst->dvar_templ_args);
   _fx_free_N10Ast__typ_t(&dst->dvar_alias);
   _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&dst->dvar_cases);
   fx_free_list_simple(&dst->dvar_ctors);
   _fx_free_rLR9Ast__id_t(&dst->dvar_templ_inst);
   _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(&dst->dvar_ifaces);
   fx_free_list_simple(&dst->dvar_scope);
}

static void _fx_copy_R17Ast__defvariant_t(struct _fx_R17Ast__defvariant_t* src, struct _fx_R17Ast__defvariant_t* dst)
{
   dst->dvar_name = src->dvar_name;
   FX_COPY_PTR(src->dvar_templ_args, &dst->dvar_templ_args);
   FX_COPY_PTR(src->dvar_alias, &dst->dvar_alias);
   dst->dvar_flags = src->dvar_flags;
   FX_COPY_PTR(src->dvar_cases, &dst->dvar_cases);
   FX_COPY_PTR(src->dvar_ctors, &dst->dvar_ctors);
   FX_COPY_PTR(src->dvar_templ_inst, &dst->dvar_templ_inst);
   FX_COPY_PTR(src->dvar_ifaces, &dst->dvar_ifaces);
   FX_COPY_PTR(src->dvar_scope, &dst->dvar_scope);
   dst->dvar_loc = src->dvar_loc;
}

static void _fx_make_R17Ast__defvariant_t(
   struct _fx_R9Ast__id_t* r_dvar_name,
   struct _fx_LR9Ast__id_t_data_t* r_dvar_templ_args,
   struct _fx_N10Ast__typ_t_data_t* r_dvar_alias,
   struct _fx_R16Ast__var_flags_t* r_dvar_flags,
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* r_dvar_cases,
   struct _fx_LR9Ast__id_t_data_t* r_dvar_ctors,
   struct _fx_rLR9Ast__id_t_data_t* r_dvar_templ_inst,
   struct _fx_LT2R9Ast__id_tLTa2R9Ast__id_t_data_t* r_dvar_ifaces,
   struct _fx_LN12Ast__scope_t_data_t* r_dvar_scope,
   struct _fx_R10Ast__loc_t* r_dvar_loc,
   struct _fx_R17Ast__defvariant_t* fx_result)
{
   fx_result->dvar_name = *r_dvar_name;
   FX_COPY_PTR(r_dvar_templ_args, &fx_result->dvar_templ_args);
   FX_COPY_PTR(r_dvar_alias, &fx_result->dvar_alias);
   fx_result->dvar_flags = *r_dvar_flags;
   FX_COPY_PTR(r_dvar_cases, &fx_result->dvar_cases);
   FX_COPY_PTR(r_dvar_ctors, &fx_result->dvar_ctors);
   FX_COPY_PTR(r_dvar_templ_inst, &fx_result->dvar_templ_inst);
   FX_COPY_PTR(r_dvar_ifaces, &fx_result->dvar_ifaces);
   FX_COPY_PTR(r_dvar_scope, &fx_result->dvar_scope);
   fx_result->dvar_loc = *r_dvar_loc;
}

static void _fx_free_rR17Ast__defvariant_t(struct _fx_rR17Ast__defvariant_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rR17Ast__defvariant_t, _fx_free_R17Ast__defvariant_t);
}

static int _fx_make_rR17Ast__defvariant_t(
   struct _fx_R17Ast__defvariant_t* arg,
   struct _fx_rR17Ast__defvariant_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rR17Ast__defvariant_t, _fx_copy_R17Ast__defvariant_t);
}

static void _fx_free_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* src,
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_R16Ast__fun_flags_t* t2,
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t,
      _fx_free_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t);
}

static int _fx_cons_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* hd,
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t,
      _fx_copy_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t);
}

static void _fx_free_R19Ast__definterface_t(struct _fx_R19Ast__definterface_t* dst)
{
   _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&dst->di_new_methods);
   _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&dst->di_all_methods);
   fx_free_list_simple(&dst->di_scope);
}

static void _fx_copy_R19Ast__definterface_t(struct _fx_R19Ast__definterface_t* src, struct _fx_R19Ast__definterface_t* dst)
{
   dst->di_name = src->di_name;
   dst->di_base = src->di_base;
   FX_COPY_PTR(src->di_new_methods, &dst->di_new_methods);
   FX_COPY_PTR(src->di_all_methods, &dst->di_all_methods);
   FX_COPY_PTR(src->di_scope, &dst->di_scope);
   dst->di_loc = src->di_loc;
}

static void _fx_make_R19Ast__definterface_t(
   struct _fx_R9Ast__id_t* r_di_name,
   struct _fx_R9Ast__id_t* r_di_base,
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* r_di_new_methods,
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* r_di_all_methods,
   struct _fx_LN12Ast__scope_t_data_t* r_di_scope,
   struct _fx_R10Ast__loc_t* r_di_loc,
   struct _fx_R19Ast__definterface_t* fx_result)
{
   fx_result->di_name = *r_di_name;
   fx_result->di_base = *r_di_base;
   FX_COPY_PTR(r_di_new_methods, &fx_result->di_new_methods);
   FX_COPY_PTR(r_di_all_methods, &fx_result->di_all_methods);
   FX_COPY_PTR(r_di_scope, &fx_result->di_scope);
   fx_result->di_loc = *r_di_loc;
}

static void _fx_free_rR19Ast__definterface_t(struct _fx_rR19Ast__definterface_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rR19Ast__definterface_t, _fx_free_R19Ast__definterface_t);
}

static int _fx_make_rR19Ast__definterface_t(
   struct _fx_R19Ast__definterface_t* arg,
   struct _fx_rR19Ast__definterface_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rR19Ast__definterface_t, _fx_copy_R19Ast__definterface_t);
}

static void _fx_free_N14Ast__id_info_t(struct _fx_N14Ast__id_info_t* dst)
{
   switch (dst->tag) {
   case 2:
      _fx_free_R13Ast__defval_t(&dst->u.IdDVal); break;
   case 3:
      _fx_free_rR13Ast__deffun_t(&dst->u.IdFun); break;
   case 4:
      _fx_free_rR13Ast__defexn_t(&dst->u.IdExn); break;
   case 5:
      _fx_free_rR13Ast__deftyp_t(&dst->u.IdTyp); break;
   case 6:
      _fx_free_rR17Ast__defvariant_t(&dst->u.IdVariant); break;
   case 7:
      _fx_free_rR19Ast__definterface_t(&dst->u.IdInterface); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_N14Ast__id_info_t(struct _fx_N14Ast__id_info_t* src, struct _fx_N14Ast__id_info_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 2:
      _fx_copy_R13Ast__defval_t(&src->u.IdDVal, &dst->u.IdDVal); break;
   case 3:
      FX_COPY_PTR(src->u.IdFun, &dst->u.IdFun); break;
   case 4:
      FX_COPY_PTR(src->u.IdExn, &dst->u.IdExn); break;
   case 5:
      FX_COPY_PTR(src->u.IdTyp, &dst->u.IdTyp); break;
   case 6:
      FX_COPY_PTR(src->u.IdVariant, &dst->u.IdVariant); break;
   case 7:
      FX_COPY_PTR(src->u.IdInterface, &dst->u.IdInterface); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_T3iA1N14Ast__id_info_tN14Ast__id_info_t(struct _fx_T3iA1N14Ast__id_info_tN14Ast__id_info_t* dst)
{
   fx_free_arr(&dst->t1);
   _fx_free_N14Ast__id_info_t(&dst->t2);
}

static void _fx_copy_T3iA1N14Ast__id_info_tN14Ast__id_info_t(
   struct _fx_T3iA1N14Ast__id_info_tN14Ast__id_info_t* src,
   struct _fx_T3iA1N14Ast__id_info_tN14Ast__id_info_t* dst)
{
   dst->t0 = src->t0;
   fx_copy_arr(&src->t1, &dst->t1);
   _fx_copy_N14Ast__id_info_t(&src->t2, &dst->t2);
}

static void _fx_make_T3iA1N14Ast__id_info_tN14Ast__id_info_t(
   int_ t0,
   fx_arr_t* t1,
   struct _fx_N14Ast__id_info_t* t2,
   struct _fx_T3iA1N14Ast__id_info_tN14Ast__id_info_t* fx_result)
{
   fx_result->t0 = t0;
   fx_copy_arr(t1, &fx_result->t1);
   _fx_copy_N14Ast__id_info_t(t2, &fx_result->t2);
}

static void _fx_free_Nt9Dynvec__t1N14Ast__id_info_t(struct _fx_Nt9Dynvec__t1N14Ast__id_info_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      _fx_free_T3iA1N14Ast__id_info_tN14Ast__id_info_t(&(*dst)->u.t); fx_free(*dst);
   }
   *dst = 0;
}

static void
   _fx_free_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
   struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
      dst)
{
   _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&dst->t1);
   _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&dst->t4);
}

static void
   _fx_copy_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
   struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
      src,
   struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
      dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
   dst->t3 = src->t3;
   FX_COPY_PTR(src->t4, &dst->t4);
}

static void
   _fx_make_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
   struct _fx_N12Map__color_t* t0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* t1,
   struct _fx_R9Ast__id_t* t2,
   struct _fx_R9Ast__id_t* t3,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* t4,
   struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
      fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
   fx_result->t3 = *t3;
   FX_COPY_PTR(t4, &fx_result->t4);
}

static void _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      _fx_free_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
         &(*dst)->u.Node);
      fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_LN16Ast__env_entry_t(struct _fx_LN16Ast__env_entry_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LN16Ast__env_entry_t, _fx_free_N16Ast__env_entry_t);
}

static int _fx_cons_LN16Ast__env_entry_t(
   struct _fx_N16Ast__env_entry_t_data_t* hd,
   struct _fx_LN16Ast__env_entry_t_data_t* tl,
   bool addref_tl,
   struct _fx_LN16Ast__env_entry_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LN16Ast__env_entry_t, FX_COPY_PTR);
}

static void
   _fx_free_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
      dst)
{
   _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t1);
   _fx_free_LN16Ast__env_entry_t(&dst->t3);
   _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t4);
}

static void
   _fx_copy_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
      src,
   struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
      dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
   FX_COPY_PTR(src->t3, &dst->t3);
   FX_COPY_PTR(src->t4, &dst->t4);
}

static void
   _fx_make_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_N12Map__color_t* t0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t1,
   struct _fx_R9Ast__id_t* t2,
   struct _fx_LN16Ast__env_entry_t_data_t* t3,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t4,
   struct _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
      fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
   FX_COPY_PTR(t3, &fx_result->t3);
   FX_COPY_PTR(t4, &fx_result->t4);
}

static void _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      _fx_free_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
         &(*dst)->u.Node);
      fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_Rt6Map__t2R9Ast__id_tR9Ast__id_t(struct _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t* dst)
{
   _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&dst->root);
   fx_free_fp(&dst->cmp);
}

static void _fx_copy_Rt6Map__t2R9Ast__id_tR9Ast__id_t(
   struct _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t* src,
   struct _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t* dst)
{
   FX_COPY_PTR(src->root, &dst->root);
   FX_COPY_FP(&src->cmp, &dst->cmp);
}

static void _fx_make_Rt6Map__t2R9Ast__id_tR9Ast__id_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* r_root,
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t* r_cmp,
   struct _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t* fx_result)
{
   FX_COPY_PTR(r_root, &fx_result->root);
   FX_COPY_FP(r_cmp, &fx_result->cmp);
}

static void _fx_free_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
   struct _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* dst)
{
   _fx_free_Nt11Set__tree_t1R9Ast__id_t(&dst->t1);
   _fx_free_Nt11Set__tree_t1R9Ast__id_t(&dst->t3);
}

static void _fx_copy_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
   struct _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* src,
   struct _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
   FX_COPY_PTR(src->t3, &dst->t3);
}

static void _fx_make_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
   struct _fx_N12Set__color_t* t0,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t1,
   struct _fx_R9Ast__id_t* t2,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t3,
   struct _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
   FX_COPY_PTR(t3, &fx_result->t3);
}

static void _fx_free_Nt11Set__tree_t1R9Ast__id_t(struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      _fx_free_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(&(*dst)->u.Node);
      fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_Rt6Set__t1R9Ast__id_t(struct _fx_Rt6Set__t1R9Ast__id_t* dst)
{
   _fx_free_Nt11Set__tree_t1R9Ast__id_t(&dst->root);
   fx_free_fp(&dst->cmp);
}

static void _fx_copy_Rt6Set__t1R9Ast__id_t(struct _fx_Rt6Set__t1R9Ast__id_t* src, struct _fx_Rt6Set__t1R9Ast__id_t* dst)
{
   FX_COPY_PTR(src->root, &dst->root);
   dst->size = src->size;
   FX_COPY_FP(&src->cmp, &dst->cmp);
}

static void _fx_make_Rt6Set__t1R9Ast__id_t(
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* r_root,
   int_ r_size,
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t* r_cmp,
   struct _fx_Rt6Set__t1R9Ast__id_t* fx_result)
{
   FX_COPY_PTR(r_root, &fx_result->root);
   fx_result->size = r_size;
   FX_COPY_FP(r_cmp, &fx_result->cmp);
}

static void _fx_free_T2R10Ast__loc_tS(struct _fx_T2R10Ast__loc_tS* dst)
{
   fx_free_str(&dst->t1);
}

static void _fx_copy_T2R10Ast__loc_tS(struct _fx_T2R10Ast__loc_tS* src, struct _fx_T2R10Ast__loc_tS* dst)
{
   dst->t0 = src->t0;
   fx_copy_str(&src->t1, &dst->t1);
}

static void _fx_make_T2R10Ast__loc_tS(struct _fx_R10Ast__loc_t* t0, fx_str_t* t1, struct _fx_T2R10Ast__loc_tS* fx_result)
{
   fx_result->t0 = *t0;
   fx_copy_str(t1, &fx_result->t1);
}

static void _fx_free_N10Ast__lit_t(struct _fx_N10Ast__lit_t* dst)
{
   switch (dst->tag) {
   case 5:
      fx_free_str(&dst->u.LitString); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_N10Ast__lit_t(struct _fx_N10Ast__lit_t* src, struct _fx_N10Ast__lit_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 5:
      fx_copy_str(&src->u.LitString, &dst->u.LitString); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_rNt6option1N10Ast__typ_t(struct _fx_rNt6option1N10Ast__typ_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rNt6option1N10Ast__typ_t, _fx_free_Nt6option1N10Ast__typ_t);
}

static int _fx_make_rNt6option1N10Ast__typ_t(
   struct _fx_Nt6option1N10Ast__typ_t_data_t* arg,
   struct _fx_rNt6option1N10Ast__typ_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rNt6option1N10Ast__typ_t, FX_COPY_PTR);
}

static void _fx_free_LN10Ast__typ_t(struct _fx_LN10Ast__typ_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LN10Ast__typ_t, _fx_free_N10Ast__typ_t);
}

static int _fx_cons_LN10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* hd,
   struct _fx_LN10Ast__typ_t_data_t* tl,
   bool addref_tl,
   struct _fx_LN10Ast__typ_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LN10Ast__typ_t, FX_COPY_PTR);
}

static void _fx_free_T2LN10Ast__typ_tN10Ast__typ_t(struct _fx_T2LN10Ast__typ_tN10Ast__typ_t* dst)
{
   _fx_free_LN10Ast__typ_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2LN10Ast__typ_tN10Ast__typ_t(
   struct _fx_T2LN10Ast__typ_tN10Ast__typ_t* src,
   struct _fx_T2LN10Ast__typ_tN10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2LN10Ast__typ_tN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_T2LN10Ast__typ_tN10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2iN10Ast__typ_t(struct _fx_T2iN10Ast__typ_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2iN10Ast__typ_t(struct _fx_T2iN10Ast__typ_t* src, struct _fx_T2iN10Ast__typ_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2iN10Ast__typ_t(int_ t0, struct _fx_N10Ast__typ_t_data_t* t1, struct _fx_T2iN10Ast__typ_t* fx_result)
{
   fx_result->t0 = t0;
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   _fx_free_R16Ast__val_flags_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t2);
   _fx_free_N10Ast__exp_t(&dst->t3);
}

static void _fx_copy_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* src,
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   _fx_copy_R16Ast__val_flags_t(&src->t0, &dst->t0);
   dst->t1 = src->t1;
   FX_COPY_PTR(src->t2, &dst->t2);
   FX_COPY_PTR(src->t3, &dst->t3);
}

static void _fx_make_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_R16Ast__val_flags_t* t0,
   struct _fx_R9Ast__id_t* t1,
   struct _fx_N10Ast__typ_t_data_t* t2,
   struct _fx_N10Ast__exp_t_data_t* t3,
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result)
{
   _fx_copy_R16Ast__val_flags_t(t0, &fx_result->t0);
   fx_result->t1 = *t1;
   FX_COPY_PTR(t2, &fx_result->t2);
   FX_COPY_PTR(t3, &fx_result->t3);
}

static void _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t,
      _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t);
}

static int _fx_cons_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* hd,
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t,
      _fx_copy_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t);
}

static void _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* dst)
{
   _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&dst->t0);
}

static void _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* src,
   struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* t0,
   bool t1,
   struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

static void _fx_free_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB,
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB);
}

static int _fx_make_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* arg,
   struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB,
      _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB);
}

static void _fx_free_T2LN10Ast__typ_tR9Ast__id_t(struct _fx_T2LN10Ast__typ_tR9Ast__id_t* dst)
{
   _fx_free_LN10Ast__typ_t(&dst->t0);
}

static void _fx_copy_T2LN10Ast__typ_tR9Ast__id_t(
   struct _fx_T2LN10Ast__typ_tR9Ast__id_t* src,
   struct _fx_T2LN10Ast__typ_tR9Ast__id_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2LN10Ast__typ_tR9Ast__id_t(
   struct _fx_LN10Ast__typ_t_data_t* t0,
   struct _fx_R9Ast__id_t* t1,
   struct _fx_T2LN10Ast__typ_tR9Ast__id_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_N10Ast__typ_t(struct _fx_N10Ast__typ_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      switch ((*dst)->tag) {
      case 1:
         _fx_free_rNt6option1N10Ast__typ_t(&(*dst)->u.TypVar); break;
      case 2:
         _fx_free_Nt6option1N10Ast__typ_t(&(*dst)->u.TypVarTuple); break;
      case 3:
         _fx_free_N10Ast__typ_t(&(*dst)->u.TypVarArray); break;
      case 14:
         _fx_free_T2LN10Ast__typ_tN10Ast__typ_t(&(*dst)->u.TypFun); break;
      case 15:
         _fx_free_N10Ast__typ_t(&(*dst)->u.TypList); break;
      case 16:
         _fx_free_N10Ast__typ_t(&(*dst)->u.TypVector); break;
      case 17:
         _fx_free_LN10Ast__typ_t(&(*dst)->u.TypTuple); break;
      case 18:
         _fx_free_N10Ast__typ_t(&(*dst)->u.TypRef); break;
      case 19:
         _fx_free_T2iN10Ast__typ_t(&(*dst)->u.TypArray); break;
      case 20:
         _fx_free_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&(*dst)->u.TypRecord); break;
      case 24:
         _fx_free_T2LN10Ast__typ_tR9Ast__id_t(&(*dst)->u.TypApp); break;
      default:
         ;
      }
      fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_N13Ast__binary_t(struct _fx_N13Ast__binary_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      switch ((*dst)->tag) {
      case 27:
         _fx_free_N13Ast__binary_t(&(*dst)->u.OpAugBinary); break;
      default:
         ;
      }
      fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_T2Nt6option1N10Ast__exp_tR10Ast__loc_t(struct _fx_T2Nt6option1N10Ast__exp_tR10Ast__loc_t* dst)
{
   _fx_free_Nt6option1N10Ast__exp_t(&dst->t0);
}

static void _fx_copy_T2Nt6option1N10Ast__exp_tR10Ast__loc_t(
   struct _fx_T2Nt6option1N10Ast__exp_tR10Ast__loc_t* src,
   struct _fx_T2Nt6option1N10Ast__exp_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2Nt6option1N10Ast__exp_tR10Ast__loc_t(
   struct _fx_Nt6option1N10Ast__exp_t_data_t* t0,
   struct _fx_R10Ast__loc_t* t1,
   struct _fx_T2Nt6option1N10Ast__exp_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_T2N10Ast__typ_tR10Ast__loc_t(struct _fx_T2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t0);
}

static void _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t0,
   struct _fx_R10Ast__loc_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_Nt6option1N10Ast__exp_t(&dst->t0);
   _fx_free_Nt6option1N10Ast__exp_t(&dst->t1);
   _fx_free_Nt6option1N10Ast__exp_t(&dst->t2);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t3);
}

static void _fx_copy_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t3, &dst->t3);
}

static void _fx_make_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_Nt6option1N10Ast__exp_t_data_t* t0,
   struct _fx_Nt6option1N10Ast__exp_t_data_t* t1,
   struct _fx_Nt6option1N10Ast__exp_t_data_t* t2,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t3,
   struct _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t3, &fx_result->t3);
}

static void _fx_free_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t(struct _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__lit_t(&dst->t0);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t1);
}

static void _fx_copy_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_copy_N10Ast__lit_t(&src->t0, &dst->t0);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t1, &dst->t1);
}

static void _fx_make_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__lit_t* t0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t1,
   struct _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   _fx_copy_N10Ast__lit_t(t0, &fx_result->t0);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t1, &fx_result->t1);
}

static void _fx_free_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t(struct _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t1);
}

static void _fx_copy_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   dst->t0 = src->t0;
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t1, &dst->t1);
}

static void _fx_make_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t1,
   struct _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   fx_result->t0 = *t0;
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t1, &fx_result->t1);
}

static void _fx_free_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N13Ast__binary_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
   _fx_free_N10Ast__exp_t(&dst->t2);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t3);
}

static void _fx_copy_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t3, &dst->t3);
}

static void _fx_make_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N13Ast__binary_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_N10Ast__exp_t_data_t* t2,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t3,
   struct _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t3, &fx_result->t3);
}

static void _fx_free_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t2);
}

static void _fx_copy_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t2, &dst->t2);
}

static void _fx_make_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N12Ast__unary_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t2,
   struct _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t2, &fx_result->t2);
}

static void _fx_free_LN10Ast__exp_t(struct _fx_LN10Ast__exp_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LN10Ast__exp_t, _fx_free_N10Ast__exp_t);
}

static int _fx_cons_LN10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* hd,
   struct _fx_LN10Ast__exp_t_data_t* tl,
   bool addref_tl,
   struct _fx_LN10Ast__exp_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LN10Ast__exp_t, FX_COPY_PTR);
}

static void _fx_free_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t2);
}

static void _fx_copy_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t2, &dst->t2);
}

static void _fx_make_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N13Ast__intrin_t* t0,
   struct _fx_LN10Ast__exp_t_data_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t2,
   struct _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t2, &fx_result->t2);
}

static void _fx_free_T2R9Ast__id_tN10Ast__exp_t(struct _fx_T2R9Ast__id_tN10Ast__exp_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T2R9Ast__id_tN10Ast__exp_t(
   struct _fx_T2R9Ast__id_tN10Ast__exp_t* src,
   struct _fx_T2R9Ast__id_tN10Ast__exp_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2R9Ast__id_tN10Ast__exp_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_T2R9Ast__id_tN10Ast__exp_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(struct _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t0);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t1);
}

static void _fx_copy_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t1, &dst->t1);
}

static void _fx_make_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_LN10Ast__exp_t_data_t* t0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t1,
   struct _fx_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t1, &fx_result->t1);
}

static void _fx_free_LLN10Ast__exp_t(struct _fx_LLN10Ast__exp_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LLN10Ast__exp_t, _fx_free_LN10Ast__exp_t);
}

static int _fx_cons_LLN10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* hd,
   struct _fx_LLN10Ast__exp_t_data_t* tl,
   bool addref_tl,
   struct _fx_LLN10Ast__exp_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LLN10Ast__exp_t, FX_COPY_PTR);
}

static void _fx_free_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_LLN10Ast__exp_t(&dst->t0);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t1);
}

static void _fx_copy_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t1, &dst->t1);
}

static void _fx_make_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_LLN10Ast__exp_t_data_t* t0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t1,
   struct _fx_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t1, &fx_result->t1);
}

static void _fx_free_LT2R9Ast__id_tN10Ast__exp_t(struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2R9Ast__id_tN10Ast__exp_t, _fx_free_T2R9Ast__id_tN10Ast__exp_t);
}

static int _fx_cons_LT2R9Ast__id_tN10Ast__exp_t(
   struct _fx_T2R9Ast__id_tN10Ast__exp_t* hd,
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2R9Ast__id_tN10Ast__exp_t, _fx_copy_T2R9Ast__id_tN10Ast__exp_t);
}

static void _fx_free_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t2);
}

static void _fx_copy_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t2, &dst->t2);
}

static void _fx_make_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t2,
   struct _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t2, &fx_result->t2);
}

static void _fx_free_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_LN10Ast__exp_t(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t2);
}

static void _fx_copy_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t2, &dst->t2);
}

static void _fx_make_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_LN10Ast__exp_t_data_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t2,
   struct _fx_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t2, &fx_result->t2);
}

static void _fx_free_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_LN10Ast__exp_t(&dst->t3);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t4);
}

static void _fx_copy_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
   dst->t2 = src->t2;
   FX_COPY_PTR(src->t3, &dst->t3);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t4, &dst->t4);
}

static void _fx_make_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_N13Ast__border_t* t1,
   struct _fx_N18Ast__interpolate_t* t2,
   struct _fx_LN10Ast__exp_t_data_t* t3,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t4,
   struct _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
   fx_result->t2 = *t2;
   FX_COPY_PTR(t3, &fx_result->t3);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t4, &fx_result->t4);
}

static void _fx_free_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t(struct _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t2);
}

static void _fx_copy_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t2, &dst->t2);
}

static void _fx_make_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t2,
   struct _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t2, &fx_result->t2);
}

static void _fx_free_T2N10Ast__exp_tR10Ast__loc_t(struct _fx_T2N10Ast__exp_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
}

static void _fx_copy_T2N10Ast__exp_tR10Ast__loc_t(
   struct _fx_T2N10Ast__exp_tR10Ast__loc_t* src,
   struct _fx_T2N10Ast__exp_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2N10Ast__exp_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_R10Ast__loc_t* t1,
   struct _fx_T2N10Ast__exp_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
   _fx_free_N10Ast__exp_t(&dst->t2);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t3);
}

static void _fx_copy_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t3, &dst->t3);
}

static void _fx_make_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_N10Ast__exp_t_data_t* t2,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t3,
   struct _fx_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t3, &fx_result->t3);
}

static void _fx_free_T2N10Ast__pat_tN10Ast__exp_t(struct _fx_T2N10Ast__pat_tN10Ast__exp_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T2N10Ast__pat_tN10Ast__exp_t(
   struct _fx_T2N10Ast__pat_tN10Ast__exp_t* src,
   struct _fx_T2N10Ast__pat_tN10Ast__exp_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2N10Ast__pat_tN10Ast__exp_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_T2N10Ast__pat_tN10Ast__exp_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2N10Ast__pat_tN10Ast__exp_t, _fx_free_T2N10Ast__pat_tN10Ast__exp_t);
}

static int _fx_cons_LT2N10Ast__pat_tN10Ast__exp_t(
   struct _fx_T2N10Ast__pat_tN10Ast__exp_t* hd,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2N10Ast__pat_tN10Ast__exp_t, _fx_copy_T2N10Ast__pat_tN10Ast__exp_t);
}

static void _fx_free_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t(
   struct _fx_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t* dst)
{
   _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&dst->t0);
   _fx_free_N10Ast__pat_t(&dst->t1);
   _fx_free_N10Ast__exp_t(&dst->t2);
}

static void _fx_copy_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t(
   struct _fx_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t* src,
   struct _fx_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
   dst->t3 = src->t3;
   dst->t4 = src->t4;
}

static void _fx_make_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t(
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t0,
   struct _fx_N10Ast__pat_t_data_t* t1,
   struct _fx_N10Ast__exp_t_data_t* t2,
   struct _fx_R16Ast__for_flags_t* t3,
   struct _fx_R10Ast__loc_t* t4,
   struct _fx_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
   fx_result->t3 = *t3;
   fx_result->t4 = *t4;
}

static void _fx_free_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(struct _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t* dst)
{
   _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&dst->t0);
   _fx_free_N10Ast__pat_t(&dst->t1);
}

static void _fx_copy_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(
   struct _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t* src,
   struct _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t0,
   struct _fx_N10Ast__pat_t_data_t* t1,
   struct _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t, _fx_free_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t);
}

static int _fx_cons_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(
   struct _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t* hd,
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t, _fx_copy_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t);
}

static void
   _fx_free_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t3);
}

static void
   _fx_copy_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t3, &dst->t3);
}

static void
   _fx_make_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_R16Ast__for_flags_t* t2,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t3,
   struct _fx_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t*
      fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t3, &fx_result->t3);
}

static void _fx_free_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t2);
}

static void _fx_copy_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t2, &dst->t2);
}

static void _fx_make_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t2,
   struct _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t2, &fx_result->t2);
}

static void _fx_free_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t2);
}

static void _fx_copy_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t2, &dst->t2);
}

static void _fx_make_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t2,
   struct _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t2, &fx_result->t2);
}

static void _fx_free_T2ST2N10Ast__typ_tR10Ast__loc_t(struct _fx_T2ST2N10Ast__typ_tR10Ast__loc_t* dst)
{
   fx_free_str(&dst->t0);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t1);
}

static void _fx_copy_T2ST2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T2ST2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T2ST2N10Ast__typ_tR10Ast__loc_t* dst)
{
   fx_copy_str(&src->t0, &dst->t0);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t1, &dst->t1);
}

static void _fx_make_T2ST2N10Ast__typ_tR10Ast__loc_t(
   fx_str_t* t0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t1,
   struct _fx_T2ST2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   fx_copy_str(t0, &fx_result->t0);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t1, &fx_result->t1);
}

static void _fx_free_T3SST2N10Ast__typ_tR10Ast__loc_t(struct _fx_T3SST2N10Ast__typ_tR10Ast__loc_t* dst)
{
   fx_free_str(&dst->t0);
   fx_free_str(&dst->t1);
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&dst->t2);
}

static void _fx_copy_T3SST2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3SST2N10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3SST2N10Ast__typ_tR10Ast__loc_t* dst)
{
   fx_copy_str(&src->t0, &dst->t0);
   fx_copy_str(&src->t1, &dst->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&src->t2, &dst->t2);
}

static void _fx_make_T3SST2N10Ast__typ_tR10Ast__loc_t(
   fx_str_t* t0,
   fx_str_t* t1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* t2,
   struct _fx_T3SST2N10Ast__typ_tR10Ast__loc_t* fx_result)
{
   fx_copy_str(t0, &fx_result->t0);
   fx_copy_str(t1, &fx_result->t1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(t2, &fx_result->t2);
}

static void _fx_free_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t(
   struct _fx_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
   _fx_free_R16Ast__val_flags_t(&dst->t2);
}

static void _fx_copy_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t(
   struct _fx_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t* src,
   struct _fx_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_R16Ast__val_flags_t(&src->t2, &dst->t2);
   dst->t3 = src->t3;
}

static void _fx_make_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_R16Ast__val_flags_t* t2,
   struct _fx_R10Ast__loc_t* t3,
   struct _fx_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_R16Ast__val_flags_t(t2, &fx_result->t2);
   fx_result->t3 = *t3;
}

static int _fx_cons_LT2iR9Ast__id_t(
   struct _fx_T2iR9Ast__id_t* hd,
   struct _fx_LT2iR9Ast__id_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2iR9Ast__id_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2iR9Ast__id_t, FX_COPY_SIMPLE_BY_PTR);
}

static void _fx_free_T2LT2iR9Ast__id_tR10Ast__loc_t(struct _fx_T2LT2iR9Ast__id_tR10Ast__loc_t* dst)
{
   fx_free_list_simple(&dst->t0);
}

static void _fx_copy_T2LT2iR9Ast__id_tR10Ast__loc_t(
   struct _fx_T2LT2iR9Ast__id_tR10Ast__loc_t* src,
   struct _fx_T2LT2iR9Ast__id_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2LT2iR9Ast__id_tR10Ast__loc_t(
   struct _fx_LT2iR9Ast__id_t_data_t* t0,
   struct _fx_R10Ast__loc_t* t1,
   struct _fx_T2LT2iR9Ast__id_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_T3iLR9Ast__id_tR10Ast__loc_t(struct _fx_T3iLR9Ast__id_tR10Ast__loc_t* dst)
{
   fx_free_list_simple(&dst->t1);
}

static void _fx_copy_T3iLR9Ast__id_tR10Ast__loc_t(
   struct _fx_T3iLR9Ast__id_tR10Ast__loc_t* src,
   struct _fx_T3iLR9Ast__id_tR10Ast__loc_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3iLR9Ast__id_tR10Ast__loc_t(
   int_ t0,
   struct _fx_LR9Ast__id_t_data_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3iLR9Ast__id_tR10Ast__loc_t* fx_result)
{
   fx_result->t0 = t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_T2LSR10Ast__loc_t(struct _fx_T2LSR10Ast__loc_t* dst)
{
   _fx_free_LS(&dst->t0);
}

static void _fx_copy_T2LSR10Ast__loc_t(struct _fx_T2LSR10Ast__loc_t* src, struct _fx_T2LSR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2LSR10Ast__loc_t(
   struct _fx_LS_data_t* t0,
   struct _fx_R10Ast__loc_t* t1,
   struct _fx_T2LSR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_N10Ast__exp_t(struct _fx_N10Ast__exp_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      switch ((*dst)->tag) {
      case 4:
         _fx_free_T2Nt6option1N10Ast__exp_tR10Ast__loc_t(&(*dst)->u.ExpReturn); break;
      case 5:
         _fx_free_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
            &(*dst)->u.ExpRange);
         break;
      case 6:
         _fx_free_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpLit); break;
      case 7:
         _fx_free_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpIdent); break;
      case 8:
         _fx_free_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpBinary); break;
      case 9:
         _fx_free_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpUnary); break;
      case 10:
         _fx_free_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpIntrin); break;
      case 11:
         _fx_free_T2R9Ast__id_tN10Ast__exp_t(&(*dst)->u.ExpSync); break;
      case 12:
         _fx_free_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpSeq); break;
      case 13:
         _fx_free_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpMkTuple); break;
      case 14:
         _fx_free_T2LLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpMkArray); break;
      case 15:
         _fx_free_T2LN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpMkVector); break;
      case 16:
         _fx_free_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpMkRecord); break;
      case 17:
         _fx_free_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpUpdateRecord); break;
      case 18:
         _fx_free_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpCall); break;
      case 19:
         _fx_free_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(
            &(*dst)->u.ExpAt);
         break;
      case 20:
         _fx_free_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t(&(*dst)->u.ExpAssign); break;
      case 21:
         _fx_free_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpMem); break;
      case 22:
         _fx_free_T2N10Ast__exp_tR10Ast__loc_t(&(*dst)->u.ExpThrow); break;
      case 23:
         _fx_free_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpIf); break;
      case 24:
         _fx_free_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t(&(*dst)->u.ExpWhile); break;
      case 25:
         _fx_free_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t(&(*dst)->u.ExpDoWhile); break;
      case 26:
         _fx_free_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t(&(*dst)->u.ExpFor);
         break;
      case 27:
         _fx_free_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t(
            &(*dst)->u.ExpMap);
         break;
      case 28:
         _fx_free_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpTryCatch); break;
      case 29:
         _fx_free_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpMatch); break;
      case 30:
         _fx_free_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpCast); break;
      case 31:
         _fx_free_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpTyped); break;
      case 32:
         _fx_free_T2ST2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpCCode); break;
      case 33:
         _fx_free_T3SST2N10Ast__typ_tR10Ast__loc_t(&(*dst)->u.ExpData); break;
      case 34:
         _fx_free_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t(&(*dst)->u.DefVal); break;
      case 35:
         _fx_free_rR13Ast__deffun_t(&(*dst)->u.DefFun); break;
      case 36:
         _fx_free_rR13Ast__defexn_t(&(*dst)->u.DefExn); break;
      case 37:
         _fx_free_rR13Ast__deftyp_t(&(*dst)->u.DefTyp); break;
      case 38:
         _fx_free_rR17Ast__defvariant_t(&(*dst)->u.DefVariant); break;
      case 39:
         _fx_free_rR19Ast__definterface_t(&(*dst)->u.DefInterface); break;
      case 40:
         _fx_free_T2LT2iR9Ast__id_tR10Ast__loc_t(&(*dst)->u.DirImport); break;
      case 41:
         _fx_free_T3iLR9Ast__id_tR10Ast__loc_t(&(*dst)->u.DirImportFrom); break;
      case 42:
         _fx_free_T2LSR10Ast__loc_t(&(*dst)->u.DirPragma); break;
      default:
         ;
      }
      fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_T2N10Ast__lit_tR10Ast__loc_t(struct _fx_T2N10Ast__lit_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__lit_t(&dst->t0);
}

static void _fx_copy_T2N10Ast__lit_tR10Ast__loc_t(
   struct _fx_T2N10Ast__lit_tR10Ast__loc_t* src,
   struct _fx_T2N10Ast__lit_tR10Ast__loc_t* dst)
{
   _fx_copy_N10Ast__lit_t(&src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2N10Ast__lit_tR10Ast__loc_t(
   struct _fx_N10Ast__lit_t* t0,
   struct _fx_R10Ast__loc_t* t1,
   struct _fx_T2N10Ast__lit_tR10Ast__loc_t* fx_result)
{
   _fx_copy_N10Ast__lit_t(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_T2LN10Ast__pat_tR10Ast__loc_t(struct _fx_T2LN10Ast__pat_tR10Ast__loc_t* dst)
{
   _fx_free_LN10Ast__pat_t(&dst->t0);
}

static void _fx_copy_T2LN10Ast__pat_tR10Ast__loc_t(
   struct _fx_T2LN10Ast__pat_tR10Ast__loc_t* src,
   struct _fx_T2LN10Ast__pat_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2LN10Ast__pat_tR10Ast__loc_t(
   struct _fx_LN10Ast__pat_t_data_t* t0,
   struct _fx_R10Ast__loc_t* t1,
   struct _fx_T2LN10Ast__pat_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t(struct _fx_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t* dst)
{
   _fx_free_LN10Ast__pat_t(&dst->t1);
}

static void _fx_copy_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t(
   struct _fx_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t* src,
   struct _fx_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_LN10Ast__pat_t_data_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_T2R9Ast__id_tN10Ast__pat_t(struct _fx_T2R9Ast__id_tN10Ast__pat_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t1);
}

static void _fx_copy_T2R9Ast__id_tN10Ast__pat_t(
   struct _fx_T2R9Ast__id_tN10Ast__pat_t* src,
   struct _fx_T2R9Ast__id_tN10Ast__pat_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2R9Ast__id_tN10Ast__pat_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_N10Ast__pat_t_data_t* t1,
   struct _fx_T2R9Ast__id_tN10Ast__pat_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_LT2R9Ast__id_tN10Ast__pat_t(struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2R9Ast__id_tN10Ast__pat_t, _fx_free_T2R9Ast__id_tN10Ast__pat_t);
}

static int _fx_cons_LT2R9Ast__id_tN10Ast__pat_t(
   struct _fx_T2R9Ast__id_tN10Ast__pat_t* hd,
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2R9Ast__id_tN10Ast__pat_t, _fx_copy_T2R9Ast__id_tN10Ast__pat_t);
}

static void _fx_free_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t(
   struct _fx_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t* dst)
{
   _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&dst->t1);
}

static void _fx_copy_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t(
   struct _fx_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t* src,
   struct _fx_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t(
   struct _fx_Nt6option1R9Ast__id_t* t0,
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t(struct _fx_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_N10Ast__pat_t(&dst->t1);
}

static void _fx_copy_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t(
   struct _fx_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_N10Ast__pat_t_data_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t(struct _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
}

static void _fx_copy_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t(
   struct _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
   dst->t2 = src->t2;
}

static void _fx_make_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_R9Ast__id_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
   fx_result->t2 = *t2;
}

static void _fx_free_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t(struct _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t(struct _fx_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t(
   struct _fx_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t* src,
   struct _fx_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_T2N10Ast__pat_tR10Ast__loc_t(struct _fx_T2N10Ast__pat_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
}

static void _fx_copy_T2N10Ast__pat_tR10Ast__loc_t(
   struct _fx_T2N10Ast__pat_tR10Ast__loc_t* src,
   struct _fx_T2N10Ast__pat_tR10Ast__loc_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2N10Ast__pat_tR10Ast__loc_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_R10Ast__loc_t* t1,
   struct _fx_T2N10Ast__pat_tR10Ast__loc_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_N10Ast__pat_t(struct _fx_N10Ast__pat_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      switch ((*dst)->tag) {
      case 2:
         _fx_free_T2N10Ast__lit_tR10Ast__loc_t(&(*dst)->u.PatLit); break;
      case 4:
         _fx_free_T2LN10Ast__pat_tR10Ast__loc_t(&(*dst)->u.PatTuple); break;
      case 5:
         _fx_free_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t(&(*dst)->u.PatVariant); break;
      case 6:
         _fx_free_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t(&(*dst)->u.PatRecord); break;
      case 7:
         _fx_free_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t(&(*dst)->u.PatCons); break;
      case 8:
         _fx_free_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t(&(*dst)->u.PatAs); break;
      case 9:
         _fx_free_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t(&(*dst)->u.PatTyped); break;
      case 10:
         _fx_free_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t(&(*dst)->u.PatWhen); break;
      case 11:
         _fx_free_T2LN10Ast__pat_tR10Ast__loc_t(&(*dst)->u.PatAlt); break;
      case 12:
         _fx_free_T2N10Ast__pat_tR10Ast__loc_t(&(*dst)->u.PatRef); break;
      default:
         ;
      }
      fx_free(*dst);
   }
   *dst = 0;
}

static void _fx_free_N16Ast__env_entry_t(struct _fx_N16Ast__env_entry_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      switch ((*dst)->tag) { case 2:     _fx_free_N10Ast__typ_t(&(*dst)->u.EnvTyp); break; default:    ; } fx_free(*dst);
   }
   *dst = 0;
}

static int _fx_cons_Li(int_ hd, struct _fx_Li_data_t* tl, bool addref_tl, struct _fx_Li_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_Li, FX_COPY_SIMPLE);
}

static void _fx_free_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t(
   struct _fx_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t* dst)
{
   fx_free_str(&dst->t1);
   _fx_free_LN10Ast__exp_t(&dst->t4);
   fx_free_list_simple(&dst->t5);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t6);
   _fx_free_Nt9Dynvec__t1N14Ast__id_info_t(&dst->t9);
}

static void _fx_copy_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t(
   struct _fx_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t* src,
   struct _fx_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t* dst)
{
   dst->t0 = src->t0;
   fx_copy_str(&src->t1, &dst->t1);
   dst->t2 = src->t2;
   dst->t3 = src->t3;
   FX_COPY_PTR(src->t4, &dst->t4);
   FX_COPY_PTR(src->t5, &dst->t5);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t6, &dst->t6);
   dst->t7 = src->t7;
   dst->t8 = src->t8;
   FX_COPY_PTR(src->t9, &dst->t9);
}

static void _fx_make_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t(
   struct _fx_R9Ast__id_t* t0,
   fx_str_t* t1,
   int_ t2,
   bool t3,
   struct _fx_LN10Ast__exp_t_data_t* t4,
   struct _fx_Li_data_t* t5,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t6,
   bool t7,
   int_ t8,
   struct _fx_Nt9Dynvec__t1N14Ast__id_info_t_data_t* t9,
   struct _fx_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t*
      fx_result)
{
   fx_result->t0 = *t0;
   fx_copy_str(t1, &fx_result->t1);
   fx_result->t2 = t2;
   fx_result->t3 = t3;
   FX_COPY_PTR(t4, &fx_result->t4);
   FX_COPY_PTR(t5, &fx_result->t5);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t6, &fx_result->t6);
   fx_result->t7 = t7;
   fx_result->t8 = t8;
   FX_COPY_PTR(t9, &fx_result->t9);
}

static void _fx_free_N16Ast__defmodule_t(struct _fx_N16Ast__defmodule_t_data_t** dst)
{
   if (*dst && FX_DECREF((*dst)->rc) == 1) {
      _fx_free_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t(
         &(*dst)->u.defmodule_t);
      fx_free(*dst);
   }
   *dst = 0;
}

static int _fx_cons_LR10Ast__loc_t(
   struct _fx_R10Ast__loc_t* hd,
   struct _fx_LR10Ast__loc_t_data_t* tl,
   bool addref_tl,
   struct _fx_LR10Ast__loc_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LR10Ast__loc_t, FX_COPY_SIMPLE_BY_PTR);
}

static void _fx_free_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(struct _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t* src,
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
}

static void _fx_make_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_R10Ast__loc_t* t2,
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = *t2;
}

static void _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(struct _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t, _fx_free_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t);
}

static int _fx_cons_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t* hd,
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t, _fx_copy_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t);
}

static int _fx_make_rB(bool arg, struct _fx_rB_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rB, FX_COPY_SIMPLE);
}

static void _fx_free_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* dst)
{
   switch (dst->tag) {
   case 2:
      _fx_free_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&dst->u.Some); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* src,
   struct _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 2:
      _fx_copy_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&src->u.Some, &dst->u.Some); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   switch (dst->tag) {
   case 2:
      _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&dst->u.Some); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* src,
   struct _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 2:
      _fx_copy_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&src->u.Some, &dst->u.Some); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(struct _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* dst)
{
   _fx_free_T2R9Ast__id_tN10Ast__typ_t(&dst->t0);
}

static void _fx_copy_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(
   struct _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* src,
   struct _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* dst)
{
   _fx_copy_T2R9Ast__id_tN10Ast__typ_t(&src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* t0,
   struct _fx_R9Ast__id_t* t1,
   struct _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* fx_result)
{
   _fx_copy_T2R9Ast__id_tN10Ast__typ_t(t0, &fx_result->t0);
   fx_result->t1 = *t1;
}

static void _fx_free_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(
   struct _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* dst)
{
   switch (dst->tag) {
   case 2:
      _fx_free_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&dst->u.Some); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(
   struct _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* src,
   struct _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 2:
      _fx_copy_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&src->u.Some, &dst->u.Some); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_Nt6option1N10Ast__lit_t(struct _fx_Nt6option1N10Ast__lit_t* dst)
{
   switch (dst->tag) {
   case 2:
      _fx_free_N10Ast__lit_t(&dst->u.Some); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_Nt6option1N10Ast__lit_t(struct _fx_Nt6option1N10Ast__lit_t* src, struct _fx_Nt6option1N10Ast__lit_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 2:
      _fx_copy_N10Ast__lit_t(&src->u.Some, &dst->u.Some); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_Nt6option1LN16Ast__env_entry_t(struct _fx_Nt6option1LN16Ast__env_entry_t* dst)
{
   switch (dst->tag) {
   case 2:
      _fx_free_LN16Ast__env_entry_t(&dst->u.Some); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_Nt6option1LN16Ast__env_entry_t(
   struct _fx_Nt6option1LN16Ast__env_entry_t* src,
   struct _fx_Nt6option1LN16Ast__env_entry_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 2:
      FX_COPY_PTR(src->u.Some, &dst->u.Some); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_rRt6Set__t1R9Ast__id_t(struct _fx_rRt6Set__t1R9Ast__id_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rRt6Set__t1R9Ast__id_t, _fx_free_Rt6Set__t1R9Ast__id_t);
}

static int _fx_make_rRt6Set__t1R9Ast__id_t(
   struct _fx_Rt6Set__t1R9Ast__id_t* arg,
   struct _fx_rRt6Set__t1R9Ast__id_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rRt6Set__t1R9Ast__id_t, _fx_copy_Rt6Set__t1R9Ast__id_t);
}

static void _fx_free_Nt6option1rRt6Set__t1R9Ast__id_t(struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t* dst)
{
   switch (dst->tag) {
   case 2:
      _fx_free_rRt6Set__t1R9Ast__id_t(&dst->u.Some); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_Nt6option1rRt6Set__t1R9Ast__id_t(
   struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t* src,
   struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 2:
      FX_COPY_PTR(src->u.Some, &dst->u.Some); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* dst)
{
   switch (dst->tag) {
   case 2:
      _fx_free_T2R9Ast__id_tN10Ast__typ_t(&dst->u.Some); break;
   default:
      ;
   }
   dst->tag = 0;
}

static void _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* src,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* dst)
{
   dst->tag = src->tag;
   switch (src->tag) {
   case 2:
      _fx_copy_T2R9Ast__id_tN10Ast__typ_t(&src->u.Some, &dst->u.Some); break;
   default:
      dst->u = src->u;
   }
}

static void _fx_free_T2N10Ast__exp_tB(struct _fx_T2N10Ast__exp_tB* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
}

static void _fx_copy_T2N10Ast__exp_tB(struct _fx_T2N10Ast__exp_tB* src, struct _fx_T2N10Ast__exp_tB* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2N10Ast__exp_tB(struct _fx_N10Ast__exp_t_data_t* t0, bool t1, struct _fx_T2N10Ast__exp_tB* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

static void _fx_free_LT2N10Ast__exp_tB(struct _fx_LT2N10Ast__exp_tB_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2N10Ast__exp_tB, _fx_free_T2N10Ast__exp_tB);
}

static int _fx_cons_LT2N10Ast__exp_tB(
   struct _fx_T2N10Ast__exp_tB* hd,
   struct _fx_LT2N10Ast__exp_tB_data_t* tl,
   bool addref_tl,
   struct _fx_LT2N10Ast__exp_tB_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2N10Ast__exp_tB, _fx_copy_T2N10Ast__exp_tB);
}

static void _fx_free_T2Nt11Set__tree_t1R9Ast__id_ti(struct _fx_T2Nt11Set__tree_t1R9Ast__id_ti* dst)
{
   _fx_free_Nt11Set__tree_t1R9Ast__id_t(&dst->t0);
}

static void _fx_copy_T2Nt11Set__tree_t1R9Ast__id_ti(
   struct _fx_T2Nt11Set__tree_t1R9Ast__id_ti* src,
   struct _fx_T2Nt11Set__tree_t1R9Ast__id_ti* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2Nt11Set__tree_t1R9Ast__id_ti(
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t0,
   int_ t1,
   struct _fx_T2Nt11Set__tree_t1R9Ast__id_ti* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

static void _fx_free_T2Nt11Set__tree_t1R9Ast__id_tB(struct _fx_T2Nt11Set__tree_t1R9Ast__id_tB* dst)
{
   _fx_free_Nt11Set__tree_t1R9Ast__id_t(&dst->t0);
}

static void _fx_copy_T2Nt11Set__tree_t1R9Ast__id_tB(
   struct _fx_T2Nt11Set__tree_t1R9Ast__id_tB* src,
   struct _fx_T2Nt11Set__tree_t1R9Ast__id_tB* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2Nt11Set__tree_t1R9Ast__id_tB(
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t0,
   bool t1,
   struct _fx_T2Nt11Set__tree_t1R9Ast__id_tB* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

static void _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t* dst)
{
   _fx_free_rNt6option1N10Ast__typ_t(&dst->t0);
   _fx_free_Nt6option1N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t* src,
   struct _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* t0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t* t1,
   struct _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t** dst)
{
   FX_FREE_LIST_IMPL(_fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t,
      _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t);
}

static int _fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t* hd,
   struct _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t,
      _fx_copy_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t);
}

static void _fx_free_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t,
      _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t);
}

static int _fx_make_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* arg,
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t, FX_COPY_PTR);
}

static void
   _fx_free_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB*
      dst)
{
   _fx_free_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&dst->t0);
   _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&dst->t1);
}

static void
   _fx_copy_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB*
      src,
   struct _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB*
      dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&src->t1, &dst->t1);
}

static void
   _fx_make_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t* t0,
   struct _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* t1,
   struct _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB*
      fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(t1, &fx_result->t1);
}

static void
   _fx_free_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t**
      dst)
{
   FX_FREE_LIST_IMPL(
      _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB,
      _fx_free_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB);
}

static int
   _fx_cons_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB*
      hd,
   struct _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      tl,
   bool addref_tl,
   struct _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t**
      fx_result)
{
   FX_MAKE_LIST_IMPL(
      _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB,
      _fx_copy_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB);
}

static void
   _fx_free_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t**
      dst)
{
   FX_FREE_REF_IMPL(
      _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB,
      _fx_free_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB);
}

static int
   _fx_make_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      arg,
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t**
      fx_result)
{
   FX_MAKE_REF_IMPL(
      _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB,
      FX_COPY_PTR);
}

static void _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(
   struct _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB* dst)
{
   _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t0);
}

static void _fx_copy_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(
   struct _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB* src,
   struct _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t0,
   bool t1,
   struct _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

static void _fx_free_T2N10Ast__exp_tN10Ast__typ_t(struct _fx_T2N10Ast__exp_tN10Ast__typ_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2N10Ast__exp_tN10Ast__typ_t(
   struct _fx_T2N10Ast__exp_tN10Ast__typ_t* src,
   struct _fx_T2N10Ast__exp_tN10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2N10Ast__exp_tN10Ast__typ_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_T2N10Ast__exp_tN10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2LN10Ast__exp_tLN10Ast__typ_t(struct _fx_T2LN10Ast__exp_tLN10Ast__typ_t* dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t0);
   _fx_free_LN10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2LN10Ast__exp_tLN10Ast__typ_t(
   struct _fx_T2LN10Ast__exp_tLN10Ast__typ_t* src,
   struct _fx_T2LN10Ast__exp_tLN10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2LN10Ast__exp_tLN10Ast__typ_t(
   struct _fx_LN10Ast__exp_t_data_t* t0,
   struct _fx_LN10Ast__typ_t_data_t* t1,
   struct _fx_T2LN10Ast__exp_tLN10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* src,
   struct _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_R9Ast__id_t* t0,
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* t1,
   struct _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result)
{
   fx_result->t0 = *t0;
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t(
   struct _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t* dst)
{
   _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&dst->t0);
   _fx_free_LN16Ast__env_entry_t(&dst->t1);
}

static void _fx_copy_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t(
   struct _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t* src,
   struct _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t* dst)
{
   _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t(
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* t0,
   struct _fx_LN16Ast__env_entry_t_data_t* t1,
   struct _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t* fx_result)
{
   _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_rLN16Ast__env_entry_t(struct _fx_rLN16Ast__env_entry_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rLN16Ast__env_entry_t, _fx_free_LN16Ast__env_entry_t);
}

static int _fx_make_rLN16Ast__env_entry_t(
   struct _fx_LN16Ast__env_entry_t_data_t* arg,
   struct _fx_rLN16Ast__env_entry_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rLN16Ast__env_entry_t, FX_COPY_PTR);
}

static void _fx_free_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t1);
}

static void _fx_copy_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* src,
   struct _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t1, &dst->t1);
}

static void _fx_make_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_N10Ast__typ_t_data_t* t0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t1,
   struct _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t1, &fx_result->t1);
}

static void _fx_free_Ta2N10Ast__exp_t(struct _fx_Ta2N10Ast__exp_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_N10Ast__exp_t(&dst->t1);
}

static void _fx_copy_Ta2N10Ast__exp_t(struct _fx_Ta2N10Ast__exp_t* src, struct _fx_Ta2N10Ast__exp_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_Ta2N10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_N10Ast__exp_t_data_t* t1,
   struct _fx_Ta2N10Ast__exp_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2N13Ast__binary_tNt6option1N10Ast__typ_t(struct _fx_T2N13Ast__binary_tNt6option1N10Ast__typ_t* dst)
{
   _fx_free_N13Ast__binary_t(&dst->t0);
   _fx_free_Nt6option1N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2N13Ast__binary_tNt6option1N10Ast__typ_t(
   struct _fx_T2N13Ast__binary_tNt6option1N10Ast__typ_t* src,
   struct _fx_T2N13Ast__binary_tNt6option1N10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(
   struct _fx_N13Ast__binary_t_data_t* t0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t* t1,
   struct _fx_T2N13Ast__binary_tNt6option1N10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_Ta2N10Ast__typ_t(struct _fx_Ta2N10Ast__typ_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_Ta2N10Ast__typ_t(struct _fx_Ta2N10Ast__typ_t* src, struct _fx_Ta2N10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_Ta2N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_Ta2N10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2N10Ast__exp_ti(struct _fx_T2N10Ast__exp_ti* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
}

static void _fx_copy_T2N10Ast__exp_ti(struct _fx_T2N10Ast__exp_ti* src, struct _fx_T2N10Ast__exp_ti* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2N10Ast__exp_ti(struct _fx_N10Ast__exp_t_data_t* t0, int_ t1, struct _fx_T2N10Ast__exp_ti* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

static void _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t1);
}

static void _fx_copy_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* src,
   struct _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t1, &dst->t1);
}

static void _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_LN10Ast__exp_t_data_t* t0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t1,
   struct _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t1, &fx_result->t1);
}

static void _fx_free_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(
   struct _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
}

static void _fx_copy_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(
   struct _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t* src,
   struct _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
   dst->t2 = src->t2;
}

static void _fx_make_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_N13Ast__border_t* t1,
   struct _fx_N18Ast__interpolate_t* t2,
   struct _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = *t1;
   fx_result->t2 = *t2;
}

static void _fx_free_T4LN10Ast__exp_tiii(struct _fx_T4LN10Ast__exp_tiii* dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t0);
}

static void _fx_copy_T4LN10Ast__exp_tiii(struct _fx_T4LN10Ast__exp_tiii* src, struct _fx_T4LN10Ast__exp_tiii* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
   dst->t2 = src->t2;
   dst->t3 = src->t3;
}

static void _fx_make_T4LN10Ast__exp_tiii(
   struct _fx_LN10Ast__exp_t_data_t* t0,
   int_ t1,
   int_ t2,
   int_ t3,
   struct _fx_T4LN10Ast__exp_tiii* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
   fx_result->t2 = t2;
   fx_result->t3 = t3;
}

static void
   _fx_free_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t1);
   _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&dst->t2);
   _fx_free_N10Ast__pat_t(&dst->t3);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t5);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t6);
}

static void
   _fx_copy_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      src,
   struct _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
   FX_COPY_PTR(src->t3, &dst->t3);
   dst->t4 = src->t4;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t5, &dst->t5);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t6, &dst->t6);
}

static void
   _fx_make_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   int_ t0,
   struct _fx_LN10Ast__exp_t_data_t* t1,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t2,
   struct _fx_N10Ast__pat_t_data_t* t3,
   int_ t4,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t5,
   struct _fx_Rt6Set__t1R9Ast__id_t* t6,
   struct _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      fx_result)
{
   fx_result->t0 = t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
   FX_COPY_PTR(t3, &fx_result->t3);
   fx_result->t4 = t4;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t5, &fx_result->t5);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t6, &fx_result->t6);
}

static void
   _fx_free_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t1);
   _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&dst->t2);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t4);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t5);
}

static void
   _fx_copy_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      src,
   struct _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
   dst->t3 = src->t3;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t4, &dst->t4);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t5, &dst->t5);
}

static void
   _fx_make_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   int_ t0,
   struct _fx_LN10Ast__exp_t_data_t* t1,
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t* t2,
   int_ t3,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t4,
   struct _fx_Rt6Set__t1R9Ast__id_t* t5,
   struct _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      fx_result)
{
   fx_result->t0 = t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
   fx_result->t3 = t3;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t4, &fx_result->t4);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t5, &fx_result->t5);
}

static void _fx_free_T4iLLN10Ast__exp_tBi(struct _fx_T4iLLN10Ast__exp_tBi* dst)
{
   _fx_free_LLN10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T4iLLN10Ast__exp_tBi(struct _fx_T4iLLN10Ast__exp_tBi* src, struct _fx_T4iLLN10Ast__exp_tBi* dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   dst->t2 = src->t2;
   dst->t3 = src->t3;
}

static void _fx_make_T4iLLN10Ast__exp_tBi(
   int_ t0,
   struct _fx_LLN10Ast__exp_t_data_t* t1,
   bool t2,
   int_ t3,
   struct _fx_T4iLLN10Ast__exp_tBi* fx_result)
{
   fx_result->t0 = t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   fx_result->t2 = t2;
   fx_result->t3 = t3;
}

static void _fx_free_T3BiLN10Ast__exp_t(struct _fx_T3BiLN10Ast__exp_t* dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t2);
}

static void _fx_copy_T3BiLN10Ast__exp_t(struct _fx_T3BiLN10Ast__exp_t* src, struct _fx_T3BiLN10Ast__exp_t* dst)
{
   dst->t0 = src->t0;
   dst->t1 = src->t1;
   FX_COPY_PTR(src->t2, &dst->t2);
}

static void _fx_make_T3BiLN10Ast__exp_t(
   bool t0,
   int_ t1,
   struct _fx_LN10Ast__exp_t_data_t* t2,
   struct _fx_T3BiLN10Ast__exp_t* fx_result)
{
   fx_result->t0 = t0;
   fx_result->t1 = t1;
   FX_COPY_PTR(t2, &fx_result->t2);
}

static void _fx_free_T3SiN10Ast__typ_t(struct _fx_T3SiN10Ast__typ_t* dst)
{
   fx_free_str(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t2);
}

static void _fx_copy_T3SiN10Ast__typ_t(struct _fx_T3SiN10Ast__typ_t* src, struct _fx_T3SiN10Ast__typ_t* dst)
{
   fx_copy_str(&src->t0, &dst->t0);
   dst->t1 = src->t1;
   FX_COPY_PTR(src->t2, &dst->t2);
}

static void _fx_make_T3SiN10Ast__typ_t(
   fx_str_t* t0,
   int_ t1,
   struct _fx_N10Ast__typ_t_data_t* t2,
   struct _fx_T3SiN10Ast__typ_t* fx_result)
{
   fx_copy_str(t0, &fx_result->t0);
   fx_result->t1 = t1;
   FX_COPY_PTR(t2, &fx_result->t2);
}

static void _fx_free_T4BiN10Ast__exp_tR10Ast__loc_t(struct _fx_T4BiN10Ast__exp_tR10Ast__loc_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t2);
}

static void _fx_copy_T4BiN10Ast__exp_tR10Ast__loc_t(
   struct _fx_T4BiN10Ast__exp_tR10Ast__loc_t* src,
   struct _fx_T4BiN10Ast__exp_tR10Ast__loc_t* dst)
{
   dst->t0 = src->t0;
   dst->t1 = src->t1;
   FX_COPY_PTR(src->t2, &dst->t2);
   dst->t3 = src->t3;
}

static void _fx_make_T4BiN10Ast__exp_tR10Ast__loc_t(
   bool t0,
   int_ t1,
   struct _fx_N10Ast__exp_t_data_t* t2,
   struct _fx_R10Ast__loc_t* t3,
   struct _fx_T4BiN10Ast__exp_tR10Ast__loc_t* fx_result)
{
   fx_result->t0 = t0;
   fx_result->t1 = t1;
   FX_COPY_PTR(t2, &fx_result->t2);
   fx_result->t3 = *t3;
}

static void _fx_free_T2SN10Ast__typ_t(struct _fx_T2SN10Ast__typ_t* dst)
{
   fx_free_str(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2SN10Ast__typ_t(struct _fx_T2SN10Ast__typ_t* src, struct _fx_T2SN10Ast__typ_t* dst)
{
   fx_copy_str(&src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2SN10Ast__typ_t(fx_str_t* t0, struct _fx_N10Ast__typ_t_data_t* t1, struct _fx_T2SN10Ast__typ_t* fx_result)
{
   fx_copy_str(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   _fx_free_T2R9Ast__id_tN10Ast__exp_t(&dst->t0);
   _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* src,
   struct _fx_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   _fx_copy_T2R9Ast__id_tN10Ast__exp_t(&src->t0, &dst->t0);
   _fx_copy_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&src->t1, &dst->t1);
}

static void _fx_make_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T2R9Ast__id_tN10Ast__exp_t* t0,
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* t1,
   struct _fx_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result)
{
   _fx_copy_T2R9Ast__id_tN10Ast__exp_t(t0, &fx_result->t0);
   _fx_copy_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(t1, &fx_result->t1);
}

static void _fx_free_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&dst->t0);
   _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* src,
   struct _fx_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t* t0,
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* t1,
   struct _fx_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2N10Ast__exp_tLN10Ast__exp_t(struct _fx_T2N10Ast__exp_tLN10Ast__exp_t* dst)
{
   _fx_free_N10Ast__exp_t(&dst->t0);
   _fx_free_LN10Ast__exp_t(&dst->t1);
}

static void _fx_copy_T2N10Ast__exp_tLN10Ast__exp_t(
   struct _fx_T2N10Ast__exp_tLN10Ast__exp_t* src,
   struct _fx_T2N10Ast__exp_tLN10Ast__exp_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2N10Ast__exp_tLN10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* t0,
   struct _fx_LN10Ast__exp_t_data_t* t1,
   struct _fx_T2N10Ast__exp_tLN10Ast__exp_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void
   _fx_free_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* dst)
{
   _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&dst->t1);
   _fx_free_LN10Ast__exp_t(&dst->t2);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t4);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t5);
}

static void
   _fx_copy_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* src,
   struct _fx_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* dst)
{
   dst->t0 = src->t0;
   _fx_copy_T2N10Ast__pat_tN10Ast__exp_t(&src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
   dst->t3 = src->t3;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t4, &dst->t4);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t5, &dst->t5);
}

static void
   _fx_make_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   int_ t0,
   struct _fx_T2N10Ast__pat_tN10Ast__exp_t* t1,
   struct _fx_LN10Ast__exp_t_data_t* t2,
   int_ t3,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t4,
   struct _fx_Rt6Set__t1R9Ast__id_t* t5,
   struct _fx_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      fx_result)
{
   fx_result->t0 = t0;
   _fx_copy_T2N10Ast__pat_tN10Ast__exp_t(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
   fx_result->t3 = t3;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t4, &fx_result->t4);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t5, &fx_result->t5);
}

static void _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
   struct _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t1);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t2);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t3);
}

static void _fx_copy_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
   struct _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB* src,
   struct _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t1, &dst->t1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t2, &dst->t2);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t3, &dst->t3);
   dst->t4 = src->t4;
}

static void _fx_make_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t1,
   struct _fx_Rt6Set__t1R9Ast__id_t* t2,
   struct _fx_Rt6Set__t1R9Ast__id_t* t3,
   bool t4,
   struct _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t1, &fx_result->t1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t2, &fx_result->t2);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t3, &fx_result->t3);
   fx_result->t4 = t4;
}

static void _fx_free_T2N10Ast__typ_ti(struct _fx_T2N10Ast__typ_ti* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t0);
}

static void _fx_copy_T2N10Ast__typ_ti(struct _fx_T2N10Ast__typ_ti* src, struct _fx_T2N10Ast__typ_ti* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2N10Ast__typ_ti(struct _fx_N10Ast__typ_t_data_t* t0, int_ t1, struct _fx_T2N10Ast__typ_ti* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

static void
   _fx_free_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      dst)
{
   _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&dst->t1);
   _fx_free_LN10Ast__exp_t(&dst->t2);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t4);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t5);
}

static void
   _fx_copy_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      src,
   struct _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      dst)
{
   dst->t0 = src->t0;
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
   dst->t3 = src->t3;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t4, &dst->t4);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t5, &dst->t5);
}

static void
   _fx_make_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   int_ t0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* t1,
   struct _fx_LN10Ast__exp_t_data_t* t2,
   int_ t3,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t4,
   struct _fx_Rt6Set__t1R9Ast__id_t* t5,
   struct _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      fx_result)
{
   fx_result->t0 = t0;
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
   fx_result->t3 = t3;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t4, &fx_result->t4);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t5, &fx_result->t5);
}

static void _fx_free_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t1);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t2);
}

static void _fx_copy_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* src,
   struct _fx_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t1, &dst->t1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t2, &dst->t2);
}

static void _fx_make_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t1,
   struct _fx_Rt6Set__t1R9Ast__id_t* t2,
   struct _fx_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t1, &fx_result->t1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t2, &fx_result->t2);
}

static void _fx_free_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* dst)
{
   _fx_free_LN10Ast__exp_t(&dst->t0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t1);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t2);
}

static void _fx_copy_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* src,
   struct _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t1, &dst->t1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t2, &dst->t2);
}

static void _fx_make_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_LN10Ast__exp_t_data_t* t0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t1,
   struct _fx_Rt6Set__t1R9Ast__id_t* t2,
   struct _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t1, &fx_result->t1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t2, &fx_result->t2);
}

static void _fx_free_Ta2N10Ast__pat_t(struct _fx_Ta2N10Ast__pat_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_N10Ast__pat_t(&dst->t1);
}

static void _fx_copy_Ta2N10Ast__pat_t(struct _fx_Ta2N10Ast__pat_t* src, struct _fx_Ta2N10Ast__pat_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_Ta2N10Ast__pat_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_N10Ast__pat_t_data_t* t1,
   struct _fx_Ta2N10Ast__pat_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2N10Ast__pat_tN10Ast__typ_t(struct _fx_T2N10Ast__pat_tN10Ast__typ_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2N10Ast__pat_tN10Ast__typ_t(
   struct _fx_T2N10Ast__pat_tN10Ast__typ_t* src,
   struct _fx_T2N10Ast__pat_tN10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2N10Ast__pat_tN10Ast__typ_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_T2N10Ast__pat_tN10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static int _fx_cons_LT2iR10Ast__loc_t(
   struct _fx_T2iR10Ast__loc_t* hd,
   struct _fx_LT2iR10Ast__loc_t_data_t* tl,
   bool addref_tl,
   struct _fx_LT2iR10Ast__loc_t_data_t** fx_result)
{
   FX_MAKE_LIST_IMPL(_fx_LT2iR10Ast__loc_t, FX_COPY_SIMPLE_BY_PTR);
}

static void _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(
   struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t* dst)
{
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t0);
   fx_free_list_simple(&dst->t1);
}

static void _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(
   struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t* src,
   struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t* dst)
{
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t0,
   struct _fx_LT2iR10Ast__loc_t_data_t* t1,
   struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t* fx_result)
{
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* dst)
{
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t0);
   _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&dst->t1);
}

static void _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* src,
   struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* dst)
{
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t0,
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* t1,
   struct _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* fx_result)
{
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void
   _fx_free_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
   struct _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB*
      dst)
{
   _fx_free_LN10Ast__pat_t(&dst->t0);
   _fx_free_LN10Ast__typ_t(&dst->t1);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t2);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t3);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t4);
}

static void
   _fx_copy_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
   struct _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB*
      src,
   struct _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB*
      dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t2, &dst->t2);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t3, &dst->t3);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t4, &dst->t4);
   dst->t5 = src->t5;
}

static void
   _fx_make_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
   struct _fx_LN10Ast__pat_t_data_t* t0,
   struct _fx_LN10Ast__typ_t_data_t* t1,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t2,
   struct _fx_Rt6Set__t1R9Ast__id_t* t3,
   struct _fx_Rt6Set__t1R9Ast__id_t* t4,
   bool t5,
   struct _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB*
      fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t2, &fx_result->t2);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t3, &fx_result->t3);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t4, &fx_result->t4);
   fx_result->t5 = t5;
}

static void _fx_free_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t(struct _fx_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t1);
}

static void _fx_copy_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t(
   struct _fx_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t* src,
   struct _fx_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t1, &dst->t1);
}

static void _fx_make_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t(
   struct _fx_N10Ast__pat_t_data_t* t0,
   struct _fx_Rt6Set__t1R9Ast__id_t* t1,
   struct _fx_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t1, &fx_result->t1);
}

static void _fx_free_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(struct _fx_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB* dst)
{
   _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&dst->t0);
}

static void _fx_copy_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(
   struct _fx_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB* src,
   struct _fx_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* t0,
   bool t1,
   struct _fx_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

static void _fx_free_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t** dst)
{
   FX_FREE_REF_IMPL(_fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t, _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t);
}

static int _fx_make_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg,
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t** fx_result)
{
   FX_MAKE_REF_IMPL(_fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t, _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t);
}

static void _fx_free_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* dst)
{
   _fx_free_LN10Ast__pat_t(&dst->t0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t1);
   _fx_free_Rt6Set__t1R9Ast__id_t(&dst->t2);
}

static void _fx_copy_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* src,
   struct _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t1, &dst->t1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&src->t2, &dst->t2);
}

static void _fx_make_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
   struct _fx_LN10Ast__pat_t_data_t* t0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t1,
   struct _fx_Rt6Set__t1R9Ast__id_t* t2,
   struct _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t1, &fx_result->t1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(t2, &fx_result->t2);
}

static void _fx_free_T2rR17Ast__defvariant_tN10Ast__typ_t(struct _fx_T2rR17Ast__defvariant_tN10Ast__typ_t* dst)
{
   _fx_free_rR17Ast__defvariant_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2rR17Ast__defvariant_tN10Ast__typ_t(
   struct _fx_T2rR17Ast__defvariant_tN10Ast__typ_t* src,
   struct _fx_T2rR17Ast__defvariant_tN10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2rR17Ast__defvariant_tN10Ast__typ_t(
   struct _fx_rR17Ast__defvariant_t_data_t* t0,
   struct _fx_N10Ast__typ_t_data_t* t1,
   struct _fx_T2rR17Ast__defvariant_tN10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t(struct _fx_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t* dst)
{
   fx_free_list_simple(&dst->t0);
   _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&dst->t1);
}

static void _fx_copy_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t(
   struct _fx_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t* src,
   struct _fx_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t(
   struct _fx_LR9Ast__id_t_data_t* t0,
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* t1,
   struct _fx_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
   struct _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t* dst)
{
   _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&dst->t0);
   _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&dst->t1);
   _fx_free_N10Ast__exp_t(&dst->t2);
}

static void _fx_copy_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
   struct _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t* src,
   struct _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
}

static void _fx_make_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* t0,
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* t1,
   struct _fx_N10Ast__exp_t_data_t* t2,
   struct _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
}

static void _fx_free_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(struct _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t* dst)
{
   _fx_free_LN10Ast__pat_t(&dst->t0);
   _fx_free_LN10Ast__pat_t(&dst->t1);
   _fx_free_N10Ast__exp_t(&dst->t2);
}

static void _fx_copy_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(
   struct _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t* src,
   struct _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
   FX_COPY_PTR(src->t2, &dst->t2);
}

static void _fx_make_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(
   struct _fx_LN10Ast__pat_t_data_t* t0,
   struct _fx_LN10Ast__pat_t_data_t* t1,
   struct _fx_N10Ast__exp_t_data_t* t2,
   struct _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
   FX_COPY_PTR(t2, &fx_result->t2);
}

static void _fx_free_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t(
   struct _fx_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t* dst)
{
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t1);
   _fx_free_N10Ast__typ_t(&dst->t3);
   _fx_free_rR17Ast__defvariant_t(&dst->t4);
}

static void _fx_copy_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t(
   struct _fx_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t* src,
   struct _fx_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t* dst)
{
   dst->t0 = src->t0;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&src->t1, &dst->t1);
   dst->t2 = src->t2;
   FX_COPY_PTR(src->t3, &dst->t3);
   FX_COPY_PTR(src->t4, &dst->t4);
}

static void _fx_make_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t(
   bool t0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* t1,
   struct _fx_R9Ast__id_t* t2,
   struct _fx_N10Ast__typ_t_data_t* t3,
   struct _fx_rR17Ast__defvariant_t_data_t* t4,
   struct _fx_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t* fx_result)
{
   fx_result->t0 = t0;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t1, &fx_result->t1);
   fx_result->t2 = *t2;
   FX_COPY_PTR(t3, &fx_result->t3);
   FX_COPY_PTR(t4, &fx_result->t4);
}

static void _fx_free_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(struct _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t* dst)
{
   _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&dst->t0);
   fx_free_list_simple(&dst->t1);
}

static void _fx_copy_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(
   struct _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t* src,
   struct _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   FX_COPY_PTR(src->t1, &dst->t1);
}

static void _fx_make_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* t0,
   struct _fx_LR9Ast__id_t_data_t* t1,
   struct _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   FX_COPY_PTR(t1, &fx_result->t1);
}

static void _fx_free_T2N10Ast__pat_tB(struct _fx_T2N10Ast__pat_tB* dst)
{
   _fx_free_N10Ast__pat_t(&dst->t0);
}

static void _fx_copy_T2N10Ast__pat_tB(struct _fx_T2N10Ast__pat_tB* src, struct _fx_T2N10Ast__pat_tB* dst)
{
   FX_COPY_PTR(src->t0, &dst->t0);
   dst->t1 = src->t1;
}

static void _fx_make_T2N10Ast__pat_tB(struct _fx_N10Ast__pat_t_data_t* t0, bool t1, struct _fx_T2N10Ast__pat_tB* fx_result)
{
   FX_COPY_PTR(t0, &fx_result->t0);
   fx_result->t1 = t1;
}

_fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t _fx_g19Ast_typecheck__None = { 1 };
_fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t _fx_g21Ast_typecheck__None1_ = { 1 };
_fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t _fx_g21Ast_typecheck__None2_ = { 1 };
_fx_Nt6option1N10Ast__lit_t _fx_g21Ast_typecheck__None3_ = { 1 };
_fx_Nt6option1LN16Ast__env_entry_t _fx_g21Ast_typecheck__None4_ = { 1 };
_fx_Nt6option1rRt6Set__t1R9Ast__id_t _fx_g21Ast_typecheck__None5_ = { 1 };
_fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t _fx_g21Ast_typecheck__None6_ = { 1 };
_fx_Nt6option1FPN10Ast__pat_t2N10Ast__pat_tR16Ast__ast_callb_t _fx_g21Ast_typecheck__None7_ = 0;
_fx_Nt6option1FPN10Ast__exp_t2N10Ast__exp_tR16Ast__ast_callb_t _fx_g21Ast_typecheck__None8_ = 0;
_fx_Nt6option1R9Ast__id_t _fx_g21Ast_typecheck__None9_ = { 1 };
_fx_Nt6option1N10Ast__exp_t _fx_g22Ast_typecheck__None10_ = 0;
_fx_Nt6option1N10Ast__typ_t _fx_g22Ast_typecheck__None11_ = 0;
_fx_N12Map__color_t _fx_g18Ast_typecheck__Red = { 1 };
_fx_N12Map__color_t _fx_g20Ast_typecheck__Black = { 2 };
_fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t _fx_g20Ast_typecheck__Empty = 0;
_fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t _fx_g22Ast_typecheck__Empty1_ = 0;
_fx_N12Set__color_t _fx_g20Ast_typecheck__Red1_ = { 1 };
_fx_N12Set__color_t _fx_g22Ast_typecheck__Black1_ = { 2 };
_fx_Nt11Set__tree_t1R9Ast__id_t _fx_g22Ast_typecheck__Empty2_ = 0;
_fx_N10Ast__lit_t _fx_g23Ast_typecheck__LitEmpty = { 8 };
static _fx_N10Ast__typ_t_data_t TypInt_data_2 = { 1, 5 };
_fx_N10Ast__typ_t _fx_g21Ast_typecheck__TypInt = &TypInt_data_2;
static _fx_N10Ast__typ_t_data_t TypString_data_2 = { 1, 10 };
_fx_N10Ast__typ_t _fx_g24Ast_typecheck__TypString = &TypString_data_2;
static _fx_N10Ast__typ_t_data_t TypChar_data_2 = { 1, 11 };
_fx_N10Ast__typ_t _fx_g22Ast_typecheck__TypChar = &TypChar_data_2;
static _fx_N10Ast__typ_t_data_t TypBool_data_2 = { 1, 12 };
_fx_N10Ast__typ_t _fx_g22Ast_typecheck__TypBool = &TypBool_data_2;
static _fx_N10Ast__typ_t_data_t TypVoid_data_2 = { 1, 13 };
_fx_N10Ast__typ_t _fx_g22Ast_typecheck__TypVoid = &TypVoid_data_2;
static _fx_N10Ast__typ_t_data_t TypExn_data_1 = { 1, 21 };
_fx_N10Ast__typ_t _fx_g21Ast_typecheck__TypExn = &TypExn_data_1;
static _fx_N10Ast__typ_t_data_t TypModule_data_1 = { 1, 26 };
_fx_N10Ast__typ_t _fx_g24Ast_typecheck__TypModule = &TypModule_data_1;
_fx_N12Ast__cmpop_t _fx_g20Ast_typecheck__CmpEQ = { 1 };
static _fx_N13Ast__binary_t_data_t OpAdd_data_2 = { 1, 1 };
_fx_N13Ast__binary_t _fx_g20Ast_typecheck__OpAdd = &OpAdd_data_2;
static _fx_N13Ast__binary_t_data_t OpBitwiseAnd_data_2 = { 1, 16 };
_fx_N13Ast__binary_t _fx_g27Ast_typecheck__OpBitwiseAnd = &OpBitwiseAnd_data_2;
static _fx_N13Ast__binary_t_data_t OpCons_data_1 = { 1, 26 };
_fx_N13Ast__binary_t _fx_g21Ast_typecheck__OpCons = &OpCons_data_1;
_fx_N12Ast__unary_t _fx_g22Ast_typecheck__OpMkRef = { 6 };
_fx_N12Ast__unary_t _fx_g22Ast_typecheck__OpDeref = { 7 };
_fx_N12Ast__unary_t _fx_g23Ast_typecheck__OpExpand = { 8 };
_fx_N13Ast__intrin_t _fx_g31Ast_typecheck__IntrinVariantTag = { 2 };
_fx_N13Ast__intrin_t _fx_g31Ast_typecheck__IntrinQueryIface = { 4 };
_fx_N13Ast__intrin_t _fx_g30Ast_typecheck__IntrinGetObject = { 5 };
_fx_N13Ast__intrin_t _fx_g28Ast_typecheck__IntrinGetSize = { 9 };
_fx_N13Ast__intrin_t _fx_g25Ast_typecheck__IntrinGEMM = { 13 };
_fx_N13Ast__border_t _fx_g25Ast_typecheck__BorderNone = { 1 };
_fx_N13Ast__border_t _fx_g25Ast_typecheck__BorderClip = { 2 };
_fx_N13Ast__border_t _fx_g25Ast_typecheck__BorderWrap = { 3 };
_fx_N13Ast__border_t _fx_g25Ast_typecheck__BorderZero = { 4 };
_fx_N18Ast__interpolate_t _fx_g25Ast_typecheck__InterpNone = { 1 };
_fx_N18Ast__interpolate_t _fx_g27Ast_typecheck__InterpLinear = { 2 };
FX_EXTERN_C bool _fx_M13Ast_typecheckFM6__eq__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* a,
   struct _fx_rNt6option1N10Ast__typ_t_data_t* b,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6__eq__B2RM4id_tRM4id_t(
   struct _fx_R9Ast__id_t* a_0,
   struct _fx_R9Ast__id_t* b_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C bool _fx_M13Ast_typecheckFM8__same__B2LN10Ast__typ_tLN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* a,
   struct _fx_LN10Ast__typ_t_data_t* b,
   void* fx_fv);

FX_EXTERN_C int _fx_M13Ast_typecheckFM15__eq_variants__B2N10Ast__typ_tN10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* a_0,
   struct _fx_N10Ast__typ_t_data_t* b_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C void _fx_F12print_stringv1S(fx_str_t* a, void* fx_fv);

FX_EXTERN_C int _fx_F9make_FailE1S(fx_str_t* arg0, fx_exn_t* fx_result);

FX_EXTERN_C int _fx_M7HashsetFM9makeindexA1i1i(int_ size_0, fx_arr_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_F6assertv1B(bool f_0, void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t2rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      arg0,
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* arg1,
   struct _fx_FPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t* fx_result);

static int _fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLN10Ast__typ_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* r1_0,
   struct _fx_LN10Ast__typ_t_data_t* tl_0,
   bool* fx_result,
   void* fx_fv);

static int _fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* r1_0,
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* relems_0,
   bool* fx_result,
   void* fx_fv);

static int
   _fx_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* tl1_0,
   struct _fx_LN10Ast__typ_t_data_t* tl2_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      rec_undo_stack_ref_0,
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* undo_stack_ref_0,
   bool* fx_result,
   void* fx_fv);

static int _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   struct _fx_R10Ast__loc_t* loc_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPB1N10Ast__typ_t4R10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBN10Ast__typ_trLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      arg1,
   struct _fx_N10Ast__typ_t_data_t* arg2,
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* arg3,
   struct _fx_FPB1N10Ast__typ_t* fx_result);

FX_EXTERN_C int _fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(
   struct _fx_R9Ast__id_t* i_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_N14Ast__id_info_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

static int _fx_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11compile_errE2RM5loc_tS(
   struct _fx_R10Ast__loc_t* loc_0,
   fx_str_t* msg_0,
   fx_exn_t* fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(struct _fx_R18Options__options_t _fx_g12Options__opt)
static int _fx_M13Ast_typecheckFM13coerce_types_N10Ast__typ_t7N10Ast__typ_tN10Ast__typ_tBBBR10Ast__loc_ti(
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   bool allow_fp_0,
   bool allow_tuples_0,
   bool is_shift_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ safe_max_ubits_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(int _FX_EXN_E17Ast__CompileError)
FX_EXTERN_C int _fx_M3AstFM7TypSIntN10Ast__typ_t1i(int_ arg0, struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM7TypUIntN10Ast__typ_t1i(int_ arg0, struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM8TypFloatN10Ast__typ_t1i(int_ arg0, struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6EnvTypN16Ast__env_entry_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* arg0,
   struct _fx_N16Ast__env_entry_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM5EnvIdN16Ast__env_entry_t1RM4id_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_N16Ast__env_entry_t_data_t** fx_result);

FX_EXTERN_C_VAL(struct _fx_R10Ast__loc_t _fx_g10Ast__noloc)
FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t1Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg0,
   struct _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t*
      fx_result);

static int
   _fx_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* i_0,
   struct _fx_LN16Ast__env_entry_t_data_t* entries_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* new_env_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t3R9Ast__id_tR10Ast__loc_tLN12Ast__scope_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_LN12Ast__scope_t_data_t* arg2,
   struct _fx_FPv1N14Ast__id_info_t* fx_result);

static int _fx_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t(struct _fx_N14Ast__id_info_t* i_0, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM9get_scopeLN12Ast__scope_t1N14Ast__id_info_t(
   struct _fx_N14Ast__id_info_t* id_info_0,
   struct _fx_LN12Ast__scope_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM2ppS1RM4id_t(struct _fx_R9Ast__id_t* i_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM14get_idinfo_locRM5loc_t1N14Ast__id_info_t(
   struct _fx_N14Ast__id_info_t* id_info_0,
   struct _fx_R10Ast__loc_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6stringS1RM5loc_t(struct _fx_R10Ast__loc_t* loc_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6stringS1RM4id_t(struct _fx_R9Ast__id_t* i_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_F6stringS1l(int64_t a, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM7typ2strS1N10Ast__typ_t(struct _fx_N10Ast__typ_t_data_t* t_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM7LitSIntN10Ast__lit_t2il(int_ arg0, int64_t arg1, struct _fx_N10Ast__lit_t* fx_result);

FX_EXTERN_C int _fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__lit_t* arg0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C void _fx_M3AstFM7LitUIntN10Ast__lit_t2iq(int_ arg0, uint64_t arg1, struct _fx_N10Ast__lit_t* fx_result);

FX_EXTERN_C void _fx_M3AstFM8LitFloatN10Ast__lit_t2id(int_ arg0, double arg1, struct _fx_N10Ast__lit_t* fx_result);

FX_EXTERN_C int _fx_F6stringS1i(int_ a, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM10ExpMkTupleN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_LN10Ast__exp_t_data_t* arg0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM7dup_typN10Ast__typ_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11get_lit_typN10Ast__typ_t1N10Ast__lit_t(
   struct _fx_N10Ast__lit_t* l_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM7lit2strS1N10Ast__lit_t(struct _fx_N10Ast__lit_t* c_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(
   struct _fx_LN10Ast__typ_t_data_t* arg0,
   struct _fx_R9Ast__id_t* arg1,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM13get_bare_nameRM4id_t1RM4id_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_R9Ast__id_t* fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(struct _fx_R9Ast__id_t _fx_g9Ast__noid)
FX_EXTERN_C int
   _fx_M13Ast_typecheckFM21check_and_norm_tyargsLN10Ast__typ_t4LN10Ast__typ_tLR9Ast__id_tR10Ast__loc_tR10Ast__loc_t(
   struct _fx_LN10Ast__typ_t_data_t* actual_ty_args_0,
   struct _fx_LR9Ast__id_t_data_t* templ_args_0,
   struct _fx_R10Ast__loc_t* def_loc_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   struct _fx_LN10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(
   struct _fx_R9Ast__id_t* i_0,
   struct _fx_R9Ast__id_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t1rB(
   struct _fx_rB_data_t* arg0,
   struct _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t* fx_result);

FX_EXTERN_C int _fx_M3AstFM8walk_typN10Ast__typ_t2N10Ast__typ_tRM11ast_callb_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R16Ast__ast_callb_t* callb_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

static int _fx_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R16Ast__ast_callb_t* callb_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM14get_idinfo_typN10Ast__typ_t2N14Ast__id_info_tRM5loc_t(
   struct _fx_N14Ast__id_info_t* id_info_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_F12join_embraceS4SSSLS(
   fx_str_t* begin_0,
   fx_str_t* end_0,
   fx_str_t* sep_0,
   struct _fx_LS_data_t* strs_0,
   fx_str_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11curr_modulei1LN12Ast__scope_t(
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   int_* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM12is_unique_idB1RM4id_t(struct _fx_R9Ast__id_t* i_0, bool* fx_result, void* fx_fv);

static int
   _fx_M13Ast_typecheckFM11search_pathNt6option1N10Ast__typ_t8SiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPNt6option1N10Ast__typ_t1N16Ast__env_entry_tLN12Ast__scope_t(
   fx_str_t* n_path_0,
   int_ dot_pos_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ curr_m_idx_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env0_0,
   struct _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t* pred_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int_ _fx_M6StringFM5rfindi3SCi(fx_str_t* s, char_ c, int_ from_pos, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6get_idRM4id_t1S(fx_str_t* s_0, struct _fx_R9Ast__id_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM14get_module_envRt6Map__t2RM4id_tLN16Ast__env_entry_t1i(
   int_ m_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

static int
   _fx_M13Ast_typecheckFM11search_pathNt6option1T2R9Ast__id_tN10Ast__typ_t8SiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_tLN12Ast__scope_t(
   fx_str_t* n_path_0,
   int_ dot_pos_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ curr_m_idx_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env0_0,
   struct _fx_FPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t* pred_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tR9Ast__id_trLN16Ast__env_entry_tLN12Ast__scope_tN10Ast__typ_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_R9Ast__id_t* arg2,
   struct _fx_rLN16Ast__env_entry_t_data_t* arg3,
   struct _fx_LN12Ast__scope_t_data_t* arg4,
   struct _fx_N10Ast__typ_t_data_t* arg5,
   struct _fx_FPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t* fx_result);

static int _fx_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t(
   struct _fx_N16Ast__env_entry_t_data_t* e_0,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM9TypRecordN10Ast__typ_t1rT2LT4RM11val_flags_tRM4id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM20preprocess_templ_typT2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5LR9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_LR9Ast__id_t_data_t* templ_args_0,
   struct _fx_N10Ast__typ_t_data_t* typ_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM14is_constructorB1RM11fun_flags_t(
   struct _fx_R16Ast__fun_flags_t* flags_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM12is_fixed_typB1N10Ast__typ_t(struct _fx_N10Ast__typ_t_data_t* t_0, bool* fx_result, void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM15instantiate_funrR13Ast__deffun_t5rR13Ast__deffun_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tB(
   struct _fx_rR13Ast__deffun_t_data_t* templ_df_0,
   struct _fx_N10Ast__typ_t_data_t* inst_ftyp_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* inst_env0_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   bool instantiate_0,
   struct _fx_rR13Ast__deffun_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM19try_autogen_symbolsNt6option1T2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM13deref_typ_recN10Ast__typ_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM12make_new_typN10Ast__typ_t0(struct _fx_N10Ast__typ_t_data_t** fx_result, void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t4Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tR10Ast__loc_tLN12Ast__scope_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_LN12Ast__scope_t_data_t* arg3,
   struct _fx_FPv1N14Ast__id_info_t* fx_result);

static int _fx_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t(struct _fx_N14Ast__id_info_t* i_0, void* fx_fv);

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t2R10Ast__loc_tN10Ast__typ_t(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_FPv1N14Ast__id_info_t* fx_result);

static int _fx_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t(struct _fx_N14Ast__id_info_t* i_0, void* fx_fv);

static int
   _fx_M13Ast_typecheckFM13check_range_eNt6option1N10Ast__exp_t3Nt6option1N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_Nt6option1N10Ast__exp_t_data_t* e_opt_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Nt6option1N10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM6LitIntN10Ast__lit_t1l(int64_t arg0, struct _fx_N10Ast__lit_t* fx_result);

FX_EXTERN_C int
   _fx_M3AstFM8ExpRangeN10Ast__exp_t4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_Nt6option1N10Ast__exp_t_data_t* arg0,
   struct _fx_Nt6option1N10Ast__exp_t_data_t* arg1,
   struct _fx_Nt6option1N10Ast__exp_t_data_t* arg2,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg3,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM10get_moduleN16Ast__defmodule_t2RM4id_tRM5loc_t(
   struct _fx_R9Ast__id_t* m_id_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_N16Ast__defmodule_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(int FX_EXN_OutOfRangeError)
FX_EXTERN_C int _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C_VAL(struct _fx_R9Ast__id_t _fx_g15Ast__std__tag__)
FX_EXTERN_C int _fx_M3AstFM9get_ifacerRM14definterface_t2RM4id_tRM5loc_t(
   struct _fx_R9Ast__id_t* iface_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_rR19Ast__definterface_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1R9Ast__id_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result);

static int _fx_M13Ast_typecheckFM9is_lvalueB4BN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_t(
   bool need_mutable_id_0,
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* ectx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   bool* fx_result,
   void* fx_fv);

static int _fx_M13Ast_typecheckFM32is_mutable_lvalue_identifier_expB3N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* ectx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM9ExpAssignN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM7TypListN10Ast__typ_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N13Ast__binary_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_N10Ast__exp_t_data_t* arg2,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg3,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6stringS1N13Ast__binary_t(
   struct _fx_N13Ast__binary_t_data_t* bop_0,
   fx_str_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(struct _fx_N10Ast__typ_t_data_t* t_0, bool* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N13Ast__intrin_t* arg0,
   struct _fx_LN10Ast__exp_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

static int _fx_M13Ast_typecheckFM14is_simple_ctorB1N10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM16get_binary_fnameRM4id_t2N13Ast__binary_tRM5loc_t(
   struct _fx_N13Ast__binary_t_data_t* bop_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_R9Ast__id_t* fx_result,
   void* fx_fv);

static int
   _fx_M13Ast_typecheckFM19check_and_make_callN10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
   struct _fx_R9Ast__id_t* f_id_0,
   struct _fx_LN10Ast__exp_t_data_t* args_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* ctx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_N10Ast__typ_t_data_t* etyp_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

static int
   _fx_M13Ast_typecheckFM15maybe_make_callNt6option1N10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
   struct _fx_R9Ast__id_t* f_id_0,
   struct _fx_LN10Ast__exp_t_data_t* args_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* ctx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_N10Ast__typ_t_data_t* etyp_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Nt6option1N10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6TypVarN10Ast__typ_t1rNt6option1N10Ast__typ_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM21binary_try_remove_dotN13Ast__binary_t1N13Ast__binary_t(
   struct _fx_N13Ast__binary_t_data_t* bop_0,
   struct _fx_N13Ast__binary_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_R10Ast__loc_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11loclist2locRM5loc_t2LRM5loc_tRM5loc_t(
   struct _fx_LR10Ast__loc_t_data_t* llist_0,
   struct _fx_R10Ast__loc_t* default_loc_0,
   struct _fx_R10Ast__loc_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM8ExpThrowN10Ast__exp_t2N10Ast__exp_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6TypRefN10Ast__typ_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM8ExpUnaryN10Ast__exp_t3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N12Ast__unary_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM15get_unary_fnameRM4id_t2N12Ast__unary_tRM5loc_t(
   struct _fx_N12Ast__unary_t* uop_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_R9Ast__id_t* fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(int FX_EXN_BadArgError)
FX_EXTERN_C int _fx_M3AstFM6stringS1N12Ast__unary_t(struct _fx_N12Ast__unary_t* uop_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C bool _fx_F6__eq__B2SS(fx_str_t* a, fx_str_t* b, void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM10IntrinMathN13Ast__intrin_t1RM4id_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_N13Ast__intrin_t* fx_result);

FX_EXTERN_C int _fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(
   int_ arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6stringS1N13Ast__intrin_t(struct _fx_N13Ast__intrin_t* iop_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM10check_eseqT2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tB(
   struct _fx_LN10Ast__exp_t_data_t* eseq_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool create_sc_0,
   struct _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6ExpSeqN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_LN10Ast__exp_t_data_t* arg0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

static int _fx_M13Ast_typecheckFM16check_inside_forv5BBBLN12Ast__scope_tR10Ast__loc_t(
   bool expect_fold_loop_0,
   bool isbr_0,
   bool any_for_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM7ExpSyncN10Ast__exp_t2RM4id_tN10Ast__exp_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM7dup_expN10Ast__exp_t1N10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(struct _fx_R9Ast__id_t _fx_g18Ast__std__lambda__)
FX_EXTERN_C int
   _fx_M13Ast_typecheckFM10reg_deffunRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3rR13Ast__deffun_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_rR13Ast__deffun_t_data_t* df_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6ExpNopN10Ast__exp_t1RM5loc_t(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM11ExpMkRecordN10Ast__exp_t3N10Ast__exp_tLT2RM4id_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM7ExpCallN10Ast__exp_t3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_LN10Ast__exp_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM15get_module_nameRM4id_t1i(int_ m_0, struct _fx_R9Ast__id_t* fx_result, void* fx_fv);

static int
   _fx_M13Ast_typecheckFM10check_attrT3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t4N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* arr_0,
   struct _fx_N13Ast__border_t* border_0,
   struct _fx_N18Ast__interpolate_t* interp_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M3AstFM5ExpAtN10Ast__exp_t5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_N13Ast__border_t* arg1,
   struct _fx_N18Ast__interpolate_t* arg2,
   struct _fx_LN10Ast__exp_t_data_t* arg3,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg4,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM9TypVectorN10Ast__typ_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t** fx_result);

static int _fx_M13Ast_typecheckFM26idx_type_is_correct_scalarB4N10Ast__typ_tR10Ast__loc_tN18Ast__interpolate_tLN10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* idxtyp_0,
   struct _fx_R10Ast__loc_t* idxloc_0,
   struct _fx_N18Ast__interpolate_t* interp_0,
   struct _fx_LN10Ast__typ_t_data_t* possible_idx_typs_0,
   bool* fx_result,
   void* fx_fv);

static int
   _fx_M13Ast_typecheckFM25idx_type_is_correct_tupleT2Bi5N10Ast__typ_tR10Ast__loc_tLN10Ast__exp_tN18Ast__interpolate_tLN10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* idxtyp_0,
   struct _fx_R10Ast__loc_t* tuploc_0,
   struct _fx_LN10Ast__exp_t_data_t* idxs_0,
   struct _fx_N18Ast__interpolate_t* interp_0,
   struct _fx_LN10Ast__typ_t_data_t* possible_idx_typs_0,
   struct _fx_T2Bi* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM20get_numeric_typ_sizei2N10Ast__typ_tB(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   bool allow_tuples_0,
   int_* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM5ExpIfN10Ast__exp_t4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_N10Ast__exp_t_data_t* arg2,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg3,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM14new_loop_scopeN12Ast__scope_t2iB(
   int_ m_idx_0,
   bool nested_0,
   struct _fx_N12Ast__scope_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM8ExpWhileN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM10ExpDoWhileN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM14new_fold_scopeN12Ast__scope_t1i(int_ m_idx_0, struct _fx_N12Ast__scope_t* fx_result, void* fx_fv);

FX_EXTERN_C_VAL(struct _fx_Rt6Set__t1R9Ast__id_t _fx_g16Ast__empty_idset)
static int
   _fx_M13Ast_typecheckFM17check_for_clausesT7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t7LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tR16Ast__for_flags_tLN12Ast__scope_ti(
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* for_clauses_0,
   struct _fx_N10Ast__pat_t_data_t* idx_pat_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Set__t1R9Ast__id_t* idset_0,
   struct _fx_R16Ast__for_flags_t* flags_0,
   struct _fx_LN12Ast__scope_t_data_t* for_sc_0,
   int_ curr_m_idx_0,
   struct _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      fx_result,
   void* fx_fv);

static int
   _fx_M13Ast_typecheckFM20gen_for_in_tuprec_itN10Ast__exp_t8iLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tLN12Ast__scope_t(
   int_ idx_0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* for_clauses_0,
   struct _fx_N10Ast__pat_t_data_t* idx_pat_0,
   struct _fx_N10Ast__exp_t_data_t* body_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* for_sc_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6ExpForN10Ast__exp_t5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tRM11for_flags_tRM5loc_t(
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* arg0,
   struct _fx_N10Ast__pat_t_data_t* arg1,
   struct _fx_N10Ast__exp_t_data_t* arg2,
   struct _fx_R16Ast__for_flags_t* arg3,
   struct _fx_R10Ast__loc_t* arg4,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM15new_block_scopeN12Ast__scope_t1i(int_ m_idx_0, struct _fx_N12Ast__scope_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM13new_map_scopeN12Ast__scope_t1i(int_ m_idx_0, struct _fx_N12Ast__scope_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM17new_arr_map_scopeN12Ast__scope_t1i(
   int_ m_idx_0,
   struct _fx_N12Ast__scope_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11ExpMkVectorN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_LN10Ast__exp_t_data_t* arg0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM10ExpMkArrayN10Ast__exp_t2LLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_LLN10Ast__exp_t_data_t* arg0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

static int _fx_M13Ast_typecheckFM13check_map_typv7N10Ast__typ_tN10Ast__typ_tiR10Ast__loc_tBBi(
   struct _fx_N10Ast__typ_t_data_t* elem_typ_0,
   struct _fx_N10Ast__typ_t_data_t* coll_typ_0,
   int_ idx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   bool make_list_0,
   bool make_vector_0,
   int_ total_dims_0,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M3AstFM6ExpMapN10Ast__exp_t4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tRM11for_flags_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_R16Ast__for_flags_t* arg2,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg3,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C_VAL(struct _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t_data_t* _fx_g17Ast__all_func_ctx)
FX_EXTERN_C int _fx_M3AstFM9ExpReturnN10Ast__exp_t2Nt6option1N10Ast__exp_tRM5loc_t(
   struct _fx_Nt6option1N10Ast__exp_t_data_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M6StringFM10num_suffixS1i(int_ n_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM17default_val_flagsRM11val_flags_t0(struct _fx_R16Ast__val_flags_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M13Ast_typecheckFM9make_fp1_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1R9Ast__id_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result);

FX_EXTERN_C int _fx_M3AstFM15ExpUpdateRecordN10Ast__exp_t3N10Ast__exp_tLT2RM4id_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_LT2R9Ast__id_tN10Ast__exp_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM13new_try_scopeN12Ast__scope_t1i(int_ m_idx_0, struct _fx_N12Ast__scope_t* fx_result, void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM11check_casesLT2N10Ast__pat_tN10Ast__exp_t6LT2N10Ast__pat_tN10Ast__exp_tN10Ast__typ_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* cases_0,
   struct _fx_N10Ast__typ_t_data_t* inptyp_0,
   struct _fx_N10Ast__typ_t_data_t* outtyp_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11ExpTryCatchN10Ast__exp_t3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM8ExpMatchN10Ast__exp_t3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6gen_idRM4id_t2iS(int_ m_idx_0, fx_str_t* s_0, struct _fx_R9Ast__id_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM21default_tempval_flagsRM11val_flags_t0(struct _fx_R16Ast__val_flags_t* fx_result, void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM6IdDValN14Ast__id_info_t1RM8defval_t(
   struct _fx_R13Ast__defval_t* arg0,
   struct _fx_N14Ast__id_info_t* fx_result);

FX_EXTERN_C int _fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(
   struct _fx_R9Ast__id_t* i_0,
   struct _fx_N14Ast__id_info_t* n_0,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(
   struct _fx_N10Ast__pat_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_R16Ast__val_flags_t* arg2,
   struct _fx_R10Ast__loc_t* arg3,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM14same_or_parentB3RM4id_tRM4id_tRM5loc_t(
   struct _fx_R9Ast__id_t* iface_0,
   struct _fx_R9Ast__id_t* maybe_parent_0,
   struct _fx_R10Ast__loc_t* loc_0,
   bool* fx_result,
   void* fx_fv);

static int _fx_M13Ast_typecheckFM9make_castN10Ast__exp_t4N10Ast__exp_tN10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* e1_0,
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM14get_cast_fnameRM4id_t2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_R9Ast__id_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM8ExpTypedN10Ast__exp_t3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M6StringFM5stripS1S(fx_str_t* s, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C bool _fx_M6StringFM8endswithB2SC(fx_str_t* s, char_ suffix, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM8ExpCCodeN10Ast__exp_t2ST2N10Ast__typ_tRM5loc_t(
   fx_str_t* arg0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg1,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM7ExpDataN10Ast__exp_t3SST2N10Ast__typ_tRM5loc_t(
   fx_str_t* arg0,
   fx_str_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
   struct _fx_N10Ast__pat_t_data_t* pat_0,
   struct _fx_N10Ast__typ_t_data_t* typ_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Set__t1R9Ast__id_t* idset_0,
   struct _fx_Rt6Set__t1R9Ast__id_t* typ_vars_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool proto_mode_0,
   bool simple_pat_mode_0,
   bool is_mutable_0,
   struct _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM15compile_warningv2RM5loc_tS(struct _fx_R10Ast__loc_t* loc_0, fx_str_t* msg_0, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11get_pat_locRM5loc_t1N10Ast__pat_t(
   struct _fx_N10Ast__pat_t_data_t* p_0,
   struct _fx_R10Ast__loc_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM8PatTypedN10Ast__pat_t3N10Ast__pat_tN10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__pat_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM7dup_patN10Ast__pat_t1N10Ast__pat_t(
   struct _fx_N10Ast__pat_t_data_t* p_0,
   struct _fx_N10Ast__pat_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM14pat_skip_typedN10Ast__pat_t1N10Ast__pat_t(
   struct _fx_N10Ast__pat_t_data_t* p_0,
   struct _fx_N10Ast__pat_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(struct _fx_R9Ast__id_t _fx_g15Ast__std__pat__)
FX_EXTERN_C void _fx_M3AstFM9LitStringN10Ast__lit_t1S(fx_str_t* arg0, struct _fx_N10Ast__lit_t* fx_result);

static int _fx_M13Ast_typecheckFM13check_inside_v6LN12Ast__scope_tBR10Ast__loc_tBBS(
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool any_for_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   bool expect_fold_loop_0,
   bool isbr_0,
   fx_str_t* kw_0,
   void* fx_fv);

static int _fx_M13Ast_typecheckFM10__lambda__B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* arg0_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM10border2strS2N13Ast__border_tB(
   struct _fx_N13Ast__border_t* border_0,
   bool f_0,
   fx_str_t* fx_result,
   void* fx_fv);

static int _fx_M13Ast_typecheckFM12__lambda__1_B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* arg0_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM7ExpCastN10Ast__exp_t3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tRM5loc_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* arg2,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM15is_global_scopeB1LN12Ast__scope_t(
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM16check_directivesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_LN10Ast__exp_t_data_t* eseq_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9reg_typesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_LN10Ast__exp_t_data_t* eseq_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM11check_typesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_LN10Ast__exp_t_data_t* eseq_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12check_defexnRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3rR13Ast__defexn_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_rR13Ast__defexn_t_data_t* de_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM16push_compile_errv1E(fx_exn_t* err_0, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6dup_idRM4id_t2iRM4id_t(
   int_ m_idx_0,
   struct _fx_R9Ast__id_t* old_id_0,
   struct _fx_R9Ast__id_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12check_deffunrR13Ast__deffun_t2rR13Ast__deffun_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_rR13Ast__deffun_t_data_t* df_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_rR13Ast__deffun_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM6DefFunN10Ast__exp_t1rRM8deffun_t(
   struct _fx_rR13Ast__deffun_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t** fx_result);

FX_EXTERN_C_VAL(int _FX_EXN_E26Ast__PropagateCompileError)
FX_EXTERN_C int _fx_M3AstFM18check_compile_errsv0(void* fx_fv);

static int _fx_M13Ast_typecheckFM10__lambda__B5N16Ast__env_entry_tR9Ast__id_tBR10Ast__loc_ti(
   struct _fx_N16Ast__env_entry_t_data_t* entry_0,
   struct _fx_R9Ast__id_t* alias_0,
   bool allow_duplicate_import_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ n_0,
   bool* fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(int _FX_EXN_E4Fail)
static int
   _fx_M13Ast_typecheckFM10import_modRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tiBR10Ast__loc_ti(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_R9Ast__id_t* alias_0,
   int_ m_idx_0,
   bool allow_duplicate_import_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ curr_m_idx_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(fx_arr_t _fx_g16Ast__all_modules)
static int _fx_M13Ast_typecheckFM10__lambda__LR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t(
   struct _fx_R9Ast__id_t* k_0,
   struct _fx_LN16Ast__env_entry_t_data_t* __0,
   struct _fx_LR9Ast__id_t_data_t* l_0,
   struct _fx_LR9Ast__id_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM8IdModuleN14Ast__id_info_t1i(int_ arg0, struct _fx_N14Ast__id_info_t* fx_result);

static int
   _fx_M13Ast_typecheckFM11add_parentsRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4SSRt6Map__t2R9Ast__id_tLN16Ast__env_entry_ti(
   fx_str_t* alias_path_0,
   fx_str_t* fname_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   int_ curr_m_idx_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM19fname_always_importLRM4id_t0(struct _fx_LR9Ast__id_t_data_t** fx_result, void* fx_fv);

FX_EXTERN_C int_ _fx_M6StringFM5rfindi2SC(fx_str_t* s, char_ c, void* fx_fv);

FX_EXTERN_C int _fx_M8FilenameFM7dirnameS1S(fx_str_t* path_0, fx_str_t* fx_result, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM11find_modulei2RM4id_tS(
   struct _fx_R9Ast__id_t* mname_0,
   fx_str_t* mfname_0,
   int_* fx_result,
   void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM5IdTypN14Ast__id_info_t1rRM8deftyp_t(
   struct _fx_rR13Ast__deftyp_t_data_t* arg0,
   struct _fx_N14Ast__id_info_t* fx_result);

FX_EXTERN_C void _fx_M3AstFM9IdVariantN14Ast__id_info_t1rRM12defvariant_t(
   struct _fx_rR17Ast__defvariant_t_data_t* arg0,
   struct _fx_N14Ast__id_info_t* fx_result);

FX_EXTERN_C void _fx_M3AstFM11IdInterfaceN14Ast__id_info_t1rRM14definterface_t(
   struct _fx_rR19Ast__definterface_t_data_t* arg0,
   struct _fx_N14Ast__id_info_t* fx_result);

FX_EXTERN_C int _fx_M3AstFM17default_fun_flagsRM11fun_flags_t0(struct _fx_R16Ast__fun_flags_t* fx_result, void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM5IdFunN14Ast__id_info_t1rRM8deffun_t(
   struct _fx_rR13Ast__deffun_t_data_t* arg0,
   struct _fx_N14Ast__id_info_t* fx_result);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM19instantiate_variantT2R9Ast__id_tN10Ast__typ_t5LN10Ast__typ_trR17Ast__defvariant_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_LN10Ast__typ_t_data_t* ty_args_0,
   struct _fx_rR17Ast__defvariant_t_data_t* dvar_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM11ScInterfaceN12Ast__scope_t1RM4id_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_N12Ast__scope_t* fx_result);

FX_EXTERN_C void _fx_M3AstFM5ScFunN12Ast__scope_t1RM4id_t(struct _fx_R9Ast__id_t* arg0, struct _fx_N12Ast__scope_t* fx_result);

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t1R10Ast__loc_t(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t* fx_result);

FX_EXTERN_C_VAL(struct _fx_R9Ast__id_t _fx_g16Ast__std__self__)
FX_EXTERN_C int _fx_M3AstFM6PatAnyN10Ast__pat_t1RM5loc_t(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

static int _fx_M13Ast_typecheckFM10__lambda__Nt6option1N10Ast__typ_t1N16Ast__env_entry_t(
   struct _fx_N16Ast__env_entry_t_data_t* e_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM5IdExnN14Ast__id_info_t1rRM8defexn_t(
   struct _fx_rR13Ast__defexn_t_data_t* arg0,
   struct _fx_N14Ast__id_info_t* fx_result);

FX_EXTERN_C_VAL(struct _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t _fx_g23Ast__builtin_exceptions)
FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tNt6option1rRt6Set__t1R9Ast__id_tLN12Ast__scope_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   bool arg2,
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* arg3,
   struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t* arg4,
   struct _fx_LN12Ast__scope_t_data_t* arg5,
   struct _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t* fx_result);

static int _fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R16Ast__ast_callb_t* callb_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t7R10Ast__loc_tR9Ast__id_trRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tN10Ast__typ_tLN10Ast__typ_tB(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_R9Ast__id_t* arg1,
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* arg2,
   struct _fx_LN12Ast__scope_t_data_t* arg3,
   struct _fx_N10Ast__typ_t_data_t* arg4,
   struct _fx_LN10Ast__typ_t_data_t* arg5,
   bool arg6,
   struct _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t* fx_result);

FX_EXTERN_C bool _fx_M6StringFM10startswithB2SS(fx_str_t* s, fx_str_t* prefix, void* fx_fv);

static int _fx_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t(
   struct _fx_N16Ast__env_entry_t_data_t* entry_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C_VAL(struct _fx_LS_data_t* _fx_g24Ast__all_compile_err_ctx)
FX_EXTERN_C int
   _fx_M13Ast_typecheckFM16instantiate_fun_rR13Ast__deffun_t5rR13Ast__deffun_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tB(
   struct _fx_rR13Ast__deffun_t_data_t* templ_df_0,
   struct _fx_N10Ast__typ_t_data_t* inst_ftyp_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* inst_env0_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   bool instantiate_0,
   struct _fx_rR13Ast__deffun_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM20instantiate_fun_bodyN10Ast__exp_t7R9Ast__id_tN10Ast__typ_tLN10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* inst_name_0,
   struct _fx_N10Ast__typ_t_data_t* inst_ftyp_0,
   struct _fx_LN10Ast__pat_t_data_t* inst_args_0,
   struct _fx_N10Ast__exp_t_data_t* inst_body_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* inst_env_0,
   struct _fx_LN12Ast__scope_t_data_t* fun_sc_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM5OpCmpN13Ast__binary_t1N12Ast__cmpop_t(
   struct _fx_N12Ast__cmpop_t* arg0,
   struct _fx_N13Ast__binary_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM9PatRecordN10Ast__pat_t3Nt6option1RM4id_tLT2RM4id_tN10Ast__pat_tRM5loc_t(
   struct _fx_Nt6option1R9Ast__id_t* arg0,
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM8PatTupleN10Ast__pat_t2LN10Ast__pat_tRM5loc_t(
   struct _fx_LN10Ast__pat_t_data_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM10PatVariantN10Ast__pat_t3RM4id_tLN10Ast__pat_tRM5loc_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_LN10Ast__pat_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M6Ast_ppFM12pprint_pat_xv1N10Ast__pat_t(struct _fx_N10Ast__pat_t_data_t* p_0, void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM16empty_id_hashsetNt10Hashset__t1RM4id_t1i(
   int_ size0_0,
   struct _fx_Nt10Hashset__t1R9Ast__id_t_data_t** fx_result,
   void* fx_fv);

static int _fx_M13Ast_typecheckFM10__lambda__v5R9Ast__id_tR10Ast__loc_tR9Ast__id_tR9Ast__id_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* iname2_0,
   struct _fx_R10Ast__loc_t* dvar_loc_0,
   struct _fx_R9Ast__id_t* dvar_name_0,
   struct _fx_R9Ast__id_t* iname1_0,
   struct _fx_R10Ast__loc_t* loc_0,
   void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM11CtorVariantN17Ast__fun_constr_t1i(int_ arg0, struct _fx_N17Ast__fun_constr_t* fx_result);

static int
   _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
   struct _fx_N10Ast__pat_t_data_t* p_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R16Ast__val_flags_t* captured_val_flags_0,
   int_ curr_m_idx_0,
   bool proto_mode_0,
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* r_env_ref_0,
   struct _fx_rRt6Set__t1R9Ast__id_t_data_t* r_idset_ref_0,
   struct _fx_rRt6Set__t1R9Ast__id_t_data_t* r_typ_vars_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool simple_pat_mode_0,
   struct _fx_T2N10Ast__pat_tB* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM7PatConsN10Ast__pat_t3N10Ast__pat_tN10Ast__pat_tRM5loc_t(
   struct _fx_N10Ast__pat_t_data_t* arg0,
   struct _fx_N10Ast__pat_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM5PatAsN10Ast__pat_t3N10Ast__pat_tRM4id_tRM5loc_t(
   struct _fx_N10Ast__pat_t_data_t* arg0,
   struct _fx_R9Ast__id_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6PatRefN10Ast__pat_t2N10Ast__pat_tRM5loc_t(
   struct _fx_N10Ast__pat_t_data_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM7PatWhenN10Ast__pat_t3N10Ast__pat_tN10Ast__exp_tRM5loc_t(
   struct _fx_N10Ast__pat_t_data_t* arg0,
   struct _fx_N10Ast__exp_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM6PatAltN10Ast__pat_t2LN10Ast__pat_tRM5loc_t(
   struct _fx_LN10Ast__pat_t_data_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_N10Ast__pat_t_data_t** fx_result);

FX_EXTERN_C int _fx_M3AstFM10get_moduleN16Ast__defmodule_t1i(
   int_ m_0,
   struct _fx_N16Ast__defmodule_t_data_t** fx_result,
   void* fx_fv);

FX_EXTERN_C void _fx_M3AstFM8ScModuleN12Ast__scope_t1i(int_ arg0, struct _fx_N12Ast__scope_t* fx_result);

FX_EXTERN_C_VAL(struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t _fx_g14Ast__empty_env)
FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t2R10Ast__loc_ti(
   struct _fx_R10Ast__loc_t* arg0,
   int_ arg1,
   struct _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t*
      fx_result);

static int
   _fx_M13Ast_typecheckFM12__lambda__1_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_LN16Ast__env_entry_t_data_t* entries_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* new_env_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv);

FX_EXTERN_C int _fx_M3AstFM23get_idinfo_private_flagB1N14Ast__id_info_t(
   struct _fx_N14Ast__id_info_t* id_info_0,
   bool* fx_result,
   void* fx_fv);

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      t0;
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* t1;
} _fx_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_cldata_t;

FX_EXTERN_C void
   _fx_free_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   _fx_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_cldata_t*
      dst)
{
   _fx_free_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
      &dst->t0);
   _fx_free_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&dst->t1);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      t0;
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* t1;
} _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(
   _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t_cldata_t* dst)
{
   _fx_free_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
      &dst->t0);
   _fx_free_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&dst->t1);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_R10Ast__loc_t t0;
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      t1;
   struct _fx_N10Ast__typ_t_data_t* t2;
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* t3;
} _fx_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t(
   _fx_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t_cldata_t* dst)
{
   _fx_free_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
      &dst->t1);
   _fx_free_N10Ast__typ_t(&dst->t2);
   _fx_free_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&dst->t3);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t0;
} _fx_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t;

FX_EXTERN_C void
   _fx_free_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   _fx_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t*
      dst)
{
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t0);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_R9Ast__id_t t0;
   struct _fx_R10Ast__loc_t t1;
   struct _fx_LN12Ast__scope_t_data_t* t2;
} _fx_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t(
   _fx_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t_cldata_t* dst)
{
   FX_FREE_LIST_SIMPLE(&dst->t2);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_rB_data_t* t0;
} _fx_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   _fx_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t* dst)
{
   FX_FREE_REF_SIMPLE(&dst->t0);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t0;
   struct _fx_R10Ast__loc_t t1;
   struct _fx_R9Ast__id_t t2;
   struct _fx_rLN16Ast__env_entry_t_data_t* t3;
   struct _fx_LN12Ast__scope_t_data_t* t4;
   struct _fx_N10Ast__typ_t_data_t* t5;
} _fx_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t(
   _fx_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t_cldata_t* dst)
{
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t0);
   _fx_free_rLN16Ast__env_entry_t(&dst->t3);
   FX_FREE_LIST_SIMPLE(&dst->t4);
   _fx_free_N10Ast__typ_t(&dst->t5);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
   struct _fx_R10Ast__loc_t t2;
   struct _fx_LN12Ast__scope_t_data_t* t3;
} _fx_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t(
   _fx_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t_cldata_t* dst)
{
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t0);
   _fx_free_N10Ast__typ_t(&dst->t1);
   FX_FREE_LIST_SIMPLE(&dst->t3);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_R10Ast__loc_t t0;
   struct _fx_N10Ast__typ_t_data_t* t1;
} _fx_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t(
   _fx_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t_cldata_t* dst)
{
   _fx_free_N10Ast__typ_t(&dst->t1);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_R9Ast__id_t t0;
} _fx_M13Ast_typecheckFM10__lambda__B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_cldata_t;

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_R9Ast__id_t t0;
} _fx_M13Ast_typecheckFM12__lambda__1_B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_cldata_t;

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_R10Ast__loc_t t0;
} _fx_M13Ast_typecheckFM10__lambda__Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t;

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t t0;
   struct _fx_R10Ast__loc_t t1;
   bool t2;
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t3;
   struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t t4;
   struct _fx_LN12Ast__scope_t_data_t* t5;
} _fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   _fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t* dst)
{
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t0);
   _fx_free_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t3);
   _fx_free_Nt6option1rRt6Set__t1R9Ast__id_t(&dst->t4);
   FX_FREE_LIST_SIMPLE(&dst->t5);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_R10Ast__loc_t t0;
   struct _fx_R9Ast__id_t t1;
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t2;
   struct _fx_LN12Ast__scope_t_data_t* t3;
   struct _fx_N10Ast__typ_t_data_t* t4;
   struct _fx_LN10Ast__typ_t_data_t* t5;
   bool t6;
} _fx_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t;

FX_EXTERN_C void _fx_free_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t(
   _fx_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t* dst)
{
   _fx_free_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dst->t2);
   FX_FREE_LIST_SIMPLE(&dst->t3);
   _fx_free_N10Ast__typ_t(&dst->t4);
   _fx_free_LN10Ast__typ_t(&dst->t5);
   fx_free(dst);
}

typedef struct {
   int_ rc;
   fx_free_t free_f;
   struct _fx_R10Ast__loc_t t0;
   int_ t1;
} _fx_M13Ast_typecheckFM12__lambda__1_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t;

FX_EXTERN_C void
   _fx_M13Ast_typecheckFM4SomeNt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* arg0,
   struct _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* fx_result)
{
   fx_result->tag = 2;
   _fx_copy_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(arg0, &fx_result->u.Some);
}

FX_EXTERN_C void
   _fx_M13Ast_typecheckFM4SomeNt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* arg0,
   struct _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result)
{
   fx_result->tag = 2;
   _fx_copy_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(arg0, &fx_result->u.Some);
}

FX_EXTERN_C void
   _fx_M13Ast_typecheckFM4SomeNt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(
   struct _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* arg0,
   struct _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* fx_result)
{
   fx_result->tag = 2;
   _fx_copy_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(arg0, &fx_result->u.Some);
}

FX_EXTERN_C void _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__lit_t1N10Ast__lit_t(
   struct _fx_N10Ast__lit_t* arg0,
   struct _fx_Nt6option1N10Ast__lit_t* fx_result)
{
   fx_result->tag = 2;
   _fx_copy_N10Ast__lit_t(arg0, &fx_result->u.Some);
}

FX_EXTERN_C void _fx_M13Ast_typecheckFM4SomeNt6option1LN16Ast__env_entry_t1LN16Ast__env_entry_t(
   struct _fx_LN16Ast__env_entry_t_data_t* arg0,
   struct _fx_Nt6option1LN16Ast__env_entry_t* fx_result)
{
   fx_result->tag = 2;
   FX_COPY_PTR(arg0, &fx_result->u.Some);
}

FX_EXTERN_C void _fx_M13Ast_typecheckFM4SomeNt6option1rRt6Set__t1R9Ast__id_t1rRt6Set__t1R9Ast__id_t(
   struct _fx_rRt6Set__t1R9Ast__id_t_data_t* arg0,
   struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t* fx_result)
{
   fx_result->tag = 2;
   FX_COPY_PTR(arg0, &fx_result->u.Some);
}

FX_EXTERN_C void _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* arg0,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* fx_result)
{
   fx_result->tag = 2;
   _fx_copy_T2R9Ast__id_tN10Ast__typ_t(arg0, &fx_result->u.Some);
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM4SomeNt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   struct _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t* arg0,
   struct _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_data_t** fx_result)
{
   FX_MAKE_RECURSIVE_VARIANT_IMPL_START(_fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t);
   FX_COPY_FP(arg0, &v->u.Some);
   return 0;
}

FX_EXTERN_C void _fx_M13Ast_typecheckFM4SomeNt6option1R9Ast__id_t1R9Ast__id_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_Nt6option1R9Ast__id_t* fx_result)
{
   fx_result->tag = 2;
   fx_result->u.Some = *arg0;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* arg0,
   struct _fx_Nt6option1N10Ast__exp_t_data_t** fx_result)
{
   FX_MAKE_RECURSIVE_VARIANT_IMPL_START(_fx_Nt6option1N10Ast__exp_t);
   FX_COPY_PTR(arg0, &v->u.Some);
   return 0;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* arg0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result)
{
   FX_MAKE_RECURSIVE_VARIANT_IMPL_START(_fx_Nt6option1N10Ast__typ_t);
   FX_COPY_PTR(arg0, &v->u.Some);
   return 0;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM8value_orR9Ast__id_t2Nt6option1R9Ast__id_tR9Ast__id_t(
   struct _fx_Nt6option1R9Ast__id_t* x_0,
   struct _fx_R9Ast__id_t* defval_0,
   struct _fx_R9Ast__id_t* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (x_0->tag == 2) {
      *fx_result = x_0->u.Some;
   }
   else {
      *fx_result = *defval_0;
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM6issomeB1Nt6option1R9Ast__id_t(
   struct _fx_Nt6option1R9Ast__id_t* x_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (x_0->tag == 2) {
      *fx_result = true;
   }
   else {
      *fx_result = false;
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM6__ne__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* a_0,
   struct _fx_rNt6option1N10Ast__typ_t_data_t* b_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   bool v_0 = _fx_M13Ast_typecheckFM6__eq__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(a_0, b_0, 0);
   *fx_result = !v_0;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM6__ne__B2R9Ast__id_tR9Ast__id_t(
   struct _fx_R9Ast__id_t* a_0,
   struct _fx_R9Ast__id_t* b_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   bool res_0;
   FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(a_0, b_0, &res_0, 0), _fx_cleanup);
   *fx_result = !res_0;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int_ _fx_M13Ast_typecheckFM6lengthi1LT2R9Ast__id_tN10Ast__typ_t(
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* l,
   void* fx_fv)
{
   
return fx_list_length(l);

}

FX_EXTERN_C int_ _fx_M13Ast_typecheckFM6lengthi1LN10Ast__pat_t(struct _fx_LN10Ast__pat_t_data_t* l, void* fx_fv)
{
   
return fx_list_length(l);

}

FX_EXTERN_C int_ _fx_M13Ast_typecheckFM6lengthi1LT2N10Ast__exp_tB(struct _fx_LT2N10Ast__exp_tB_data_t* l, void* fx_fv)
{
   
return fx_list_length(l);

}

FX_EXTERN_C int_ _fx_M13Ast_typecheckFM6lengthi1LR9Ast__id_t(struct _fx_LR9Ast__id_t_data_t* l, void* fx_fv)
{
   
return fx_list_length(l);

}

FX_EXTERN_C int_ _fx_M13Ast_typecheckFM6lengthi1LN10Ast__exp_t(struct _fx_LN10Ast__exp_t_data_t* l, void* fx_fv)
{
   
return fx_list_length(l);

}

FX_EXTERN_C int_ _fx_M13Ast_typecheckFM6lengthi1LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* l,
   void* fx_fv)
{
   
return fx_list_length(l);

}

FX_EXTERN_C int_ _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(struct _fx_LN10Ast__typ_t_data_t* l, void* fx_fv)
{
   
return fx_list_length(l);

}

FX_EXTERN_C int_ _fx_M13Ast_typecheckFM6lengthi1LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
   struct _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t_data_t* l,
   void* fx_fv)
{
   
return fx_list_length(l);

}

FX_EXTERN_C void _fx_M13Ast_typecheckFM5link2LT2N10Ast__exp_tB2LT2N10Ast__exp_tBLT2N10Ast__exp_tB(
   struct _fx_LT2N10Ast__exp_tB_data_t* l1,
   struct _fx_LT2N10Ast__exp_tB_data_t* l2,
   struct _fx_LT2N10Ast__exp_tB_data_t** fx_result,
   void* fx_fv)
{
   
fx_link_lists(l1, l2, fx_result);

}

FX_EXTERN_C int _fx_M13Ast_typecheckFM7__add__LT2N10Ast__exp_tB2LT2N10Ast__exp_tBLT2N10Ast__exp_tB(
   struct _fx_LT2N10Ast__exp_tB_data_t* l1_0,
   struct _fx_LT2N10Ast__exp_tB_data_t* l2_0,
   struct _fx_LT2N10Ast__exp_tB_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (l1_0 == 0) {
      FX_COPY_PTR(l2_0, fx_result);
   }
   else if (l2_0 == 0) {
      FX_COPY_PTR(l1_0, fx_result);
   }
   else {
      _fx_LT2N10Ast__exp_tB v_0 = 0;
      _fx_LT2N10Ast__exp_tB lstend_0 = 0;
      _fx_LT2N10Ast__exp_tB lst_0 = l1_0;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_T2N10Ast__exp_tB* x_0 = &lst_0->hd;
         _fx_LT2N10Ast__exp_tB node_0 = 0;
         FX_CALL(_fx_cons_LT2N10Ast__exp_tB(x_0, 0, false, &node_0), _fx_catch_0);
         FX_LIST_APPEND(v_0, lstend_0, node_0);

      _fx_catch_0: ;
         FX_CHECK_EXN(_fx_catch_1);
      }
      _fx_M13Ast_typecheckFM5link2LT2N10Ast__exp_tB2LT2N10Ast__exp_tBLT2N10Ast__exp_tB(v_0, l2_0, fx_result, 0);

   _fx_catch_1: ;
      if (v_0) {
         _fx_free_LT2N10Ast__exp_tB(&v_0);
      }
   }
   return fx_status;
}

FX_EXTERN_C void _fx_M13Ast_typecheckFM5link2LN16Ast__env_entry_t2LN16Ast__env_entry_tLN16Ast__env_entry_t(
   struct _fx_LN16Ast__env_entry_t_data_t* l1,
   struct _fx_LN16Ast__env_entry_t_data_t* l2,
   struct _fx_LN16Ast__env_entry_t_data_t** fx_result,
   void* fx_fv)
{
   
fx_link_lists(l1, l2, fx_result);

}

FX_EXTERN_C void _fx_M13Ast_typecheckFM5link2LN10Ast__typ_t2LN10Ast__typ_tLN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* l1,
   struct _fx_LN10Ast__typ_t_data_t* l2,
   struct _fx_LN10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   
fx_link_lists(l1, l2, fx_result);

}

FX_EXTERN_C void _fx_M13Ast_typecheckFM5link2LN10Ast__exp_t2LN10Ast__exp_tLN10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* l1,
   struct _fx_LN10Ast__exp_t_data_t* l2,
   struct _fx_LN10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   
fx_link_lists(l1, l2, fx_result);

}

FX_EXTERN_C int _fx_M13Ast_typecheckFM7__add__LN10Ast__exp_t2LN10Ast__exp_tLN10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* l1_0,
   struct _fx_LN10Ast__exp_t_data_t* l2_0,
   struct _fx_LN10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (l1_0 == 0) {
      FX_COPY_PTR(l2_0, fx_result);
   }
   else if (l2_0 == 0) {
      FX_COPY_PTR(l1_0, fx_result);
   }
   else {
      _fx_LN10Ast__exp_t v_0 = 0;
      _fx_LN10Ast__exp_t lstend_0 = 0;
      _fx_LN10Ast__exp_t lst_0 = l1_0;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_N10Ast__exp_t x_0 = lst_0->hd;
         _fx_LN10Ast__exp_t node_0 = 0;
         FX_CALL(_fx_cons_LN10Ast__exp_t(x_0, 0, false, &node_0), _fx_catch_0);
         FX_LIST_APPEND(v_0, lstend_0, node_0);

      _fx_catch_0: ;
         FX_CHECK_EXN(_fx_catch_1);
      }
      _fx_M13Ast_typecheckFM5link2LN10Ast__exp_t2LN10Ast__exp_tLN10Ast__exp_t(v_0, l2_0, fx_result, 0);

   _fx_catch_1: ;
      if (v_0) {
         _fx_free_LN10Ast__exp_t(&v_0);
      }
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM6stringS1S(fx_str_t* a_0, fx_str_t* fx_result, void* fx_fv)
{
   int fx_status = 0;
   fx_copy_str(a_0, fx_result);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM6__eq__B2LN10Ast__typ_tLN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* a_0,
   struct _fx_LN10Ast__typ_t_data_t* b_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_LN10Ast__typ_t a_1 = 0;
   _fx_LN10Ast__typ_t b_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   bool result_0 = 0;
   FX_COPY_PTR(a_0, &a_1);
   FX_COPY_PTR(b_0, &b_1);
   for (;;) {
      _fx_LN10Ast__typ_t a_2 = 0;
      _fx_LN10Ast__typ_t b_2 = 0;
      FX_COPY_PTR(a_1, &a_2);
      FX_COPY_PTR(b_1, &b_2);
      if (_fx_M13Ast_typecheckFM8__same__B2LN10Ast__typ_tLN10Ast__typ_t(a_2, b_2, 0)) {
         result_0 = true; FX_BREAK(_fx_catch_3);
      }
      else {
         if (b_2 != 0) {
            if (a_2 != 0) {
               bool res_0;
               FX_CALL(_fx_M13Ast_typecheckFM15__eq_variants__B2N10Ast__typ_tN10Ast__typ_t(a_2->hd, b_2->hd, &res_0, 0),
                  _fx_catch_0);
               if (res_0) {
                  _fx_LN10Ast__typ_t* a_3 = &a_2->tl;
                  _fx_free_LN10Ast__typ_t(&a_1);
                  FX_COPY_PTR(*a_3, &a_1);
                  _fx_LN10Ast__typ_t* b_3 = &b_2->tl;
                  _fx_free_LN10Ast__typ_t(&b_1);
                  FX_COPY_PTR(*b_3, &b_1);
               }
               else {
                  result_0 = false; FX_BREAK(_fx_catch_0);
               }

            _fx_catch_0: ;
               goto _fx_endmatch_0;
            }
         }
         if (b_2 == 0) {
            if (a_2 == 0) {
               result_0 = true; FX_BREAK(_fx_catch_1);  _fx_catch_1: ; goto _fx_endmatch_0;
            }
         }
         result_0 = false;
         FX_BREAK(_fx_catch_2);

      _fx_catch_2: ;

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_3);
      }

   _fx_catch_3: ;
      if (b_2) {
         _fx_free_LN10Ast__typ_t(&b_2);
      }
      if (a_2) {
         _fx_free_LN10Ast__typ_t(&a_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = result_0;

_fx_cleanup: ;
   if (a_1) {
      _fx_free_LN10Ast__typ_t(&a_1);
   }
   if (b_1) {
      _fx_free_LN10Ast__typ_t(&b_1);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM6__eq__B2Nt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_Nt6option1N10Ast__typ_t_data_t* a_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t* b_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   if ((b_0 != 0) + 1 == 2) {
      if ((a_0 != 0) + 1 == 2) {
         FX_CALL(_fx_M13Ast_typecheckFM15__eq_variants__B2N10Ast__typ_tN10Ast__typ_t(a_0->u.Some, b_0->u.Some, fx_result, 0),
            _fx_catch_0);

      _fx_catch_0: ;
         goto _fx_endmatch_0;
      }
   }
   if ((a_0 != 0) + 1 == 1) {
      if ((b_0 != 0) + 1 == 1) {
         *fx_result = true; goto _fx_endmatch_0;
      }
   }
   *fx_result = false;

_fx_endmatch_0: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C bool
   _fx_M13Ast_typecheckFM6__eq__B2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
   struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t* a,
   struct _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t* b,
   void* fx_fv)
{
   
return a == b;

}

FX_EXTERN_C bool _fx_M13Ast_typecheckFM6__eq__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* a,
   struct _fx_rNt6option1N10Ast__typ_t_data_t* b,
   void* fx_fv)
{
   
return a == b;

}

FX_EXTERN_C int _fx_M13Ast_typecheckFM15__eq_variants__B2N12Ast__scope_tN12Ast__scope_t(
   struct _fx_N12Ast__scope_t* a_0,
   struct _fx_N12Ast__scope_t* b_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (b_0->tag == 1) {
      if (a_0->tag == 1) {
         *fx_result = a_0->u.ScBlock == b_0->u.ScBlock; goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 2) {
      _fx_T2Bi* vcase_0 = &b_0->u.ScLoop;
      if (a_0->tag == 2) {
         _fx_T2Bi* vcase_1 = &a_0->u.ScLoop;
         *fx_result = (bool)((vcase_1->t0 == vcase_0->t0) & (vcase_1->t1 == vcase_0->t1));
         goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 3) {
      if (a_0->tag == 3) {
         *fx_result = a_0->u.ScFold == b_0->u.ScFold; goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 4) {
      if (a_0->tag == 4) {
         *fx_result = a_0->u.ScArrMap == b_0->u.ScArrMap; goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 5) {
      if (a_0->tag == 5) {
         *fx_result = a_0->u.ScMap == b_0->u.ScMap; goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 6) {
      if (a_0->tag == 6) {
         *fx_result = a_0->u.ScTry == b_0->u.ScTry; goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 7) {
      if (a_0->tag == 7) {
         FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&a_0->u.ScFun, &b_0->u.ScFun, fx_result, 0), _fx_catch_0);

      _fx_catch_0: ;
         goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 8) {
      if (a_0->tag == 8) {
         FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&a_0->u.ScClass, &b_0->u.ScClass, fx_result, 0), _fx_catch_1);

      _fx_catch_1: ;
         goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 9) {
      if (a_0->tag == 9) {
         FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&a_0->u.ScInterface, &b_0->u.ScInterface, fx_result, 0), _fx_catch_2);

      _fx_catch_2: ;
         goto _fx_endmatch_0;
      }
   }
   if (b_0->tag == 10) {
      if (a_0->tag == 10) {
         *fx_result = a_0->u.ScModule == b_0->u.ScModule; goto _fx_endmatch_0;
      }
   }
   *fx_result = a_0->tag == b_0->tag;

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM15__eq_variants__B2N10Ast__typ_tN10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* a_0,
   struct _fx_N10Ast__typ_t_data_t* b_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t a_1 = 0;
   _fx_N10Ast__typ_t b_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   bool result_0 = 0;
   FX_COPY_PTR(a_0, &a_1);
   FX_COPY_PTR(b_0, &b_1);
   for (;;) {
      _fx_N10Ast__typ_t a_2 = 0;
      _fx_N10Ast__typ_t b_2 = 0;
      FX_COPY_PTR(a_1, &a_2);
      FX_COPY_PTR(b_1, &b_2);
      if (FX_REC_VARIANT_TAG(b_2) == 1) {
         if (FX_REC_VARIANT_TAG(a_2) == 1) {
            bool result_1 =
               _fx_M13Ast_typecheckFM6__eq__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(a_2->u.TypVar, b_2->u.TypVar, 0);
            result_0 = result_1;
            FX_BREAK(_fx_catch_0);

         _fx_catch_0: ;
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 2) {
         if (FX_REC_VARIANT_TAG(a_2) == 2) {
            bool result_2;
            FX_CALL(
               _fx_M13Ast_typecheckFM6__eq__B2Nt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(a_2->u.TypVarTuple,
                  b_2->u.TypVarTuple, &result_2, 0), _fx_catch_1);
            result_0 = result_2;
            FX_BREAK(_fx_catch_1);

         _fx_catch_1: ;
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 3) {
         if (FX_REC_VARIANT_TAG(a_2) == 3) {
            _fx_N10Ast__typ_t* a0_0 = &a_2->u.TypVarArray;
            _fx_free_N10Ast__typ_t(&a_1);
            FX_COPY_PTR(*a0_0, &a_1);
            _fx_N10Ast__typ_t* b0_0 = &b_2->u.TypVarArray;
            _fx_free_N10Ast__typ_t(&b_1);
            FX_COPY_PTR(*b0_0, &b_1);
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 6) {
         if (FX_REC_VARIANT_TAG(a_2) == 6) {
            result_0 = a_2->u.TypSInt == b_2->u.TypSInt; FX_BREAK(_fx_catch_2);  _fx_catch_2: ; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 7) {
         if (FX_REC_VARIANT_TAG(a_2) == 7) {
            result_0 = a_2->u.TypUInt == b_2->u.TypUInt; FX_BREAK(_fx_catch_3);  _fx_catch_3: ; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 9) {
         if (FX_REC_VARIANT_TAG(a_2) == 9) {
            result_0 = a_2->u.TypFloat == b_2->u.TypFloat; FX_BREAK(_fx_catch_4);  _fx_catch_4: ; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 14) {
         _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_0 = &b_2->u.TypFun;
         if (FX_REC_VARIANT_TAG(a_2) == 14) {
            _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_1 = &a_2->u.TypFun;
            bool v_0;
            FX_CALL(_fx_M13Ast_typecheckFM6__eq__B2LN10Ast__typ_tLN10Ast__typ_t(vcase_1->t0, vcase_0->t0, &v_0, 0),
               _fx_catch_5);
            bool v_1;
            FX_CALL(_fx_M13Ast_typecheckFM15__eq_variants__B2N10Ast__typ_tN10Ast__typ_t(vcase_1->t1, vcase_0->t1, &v_1, 0),
               _fx_catch_5);
            result_0 = (bool)(v_0 & v_1);
            FX_BREAK(_fx_catch_5);

         _fx_catch_5: ;
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 15) {
         if (FX_REC_VARIANT_TAG(a_2) == 15) {
            _fx_N10Ast__typ_t* a0_1 = &a_2->u.TypList;
            _fx_free_N10Ast__typ_t(&a_1);
            FX_COPY_PTR(*a0_1, &a_1);
            _fx_N10Ast__typ_t* b0_1 = &b_2->u.TypList;
            _fx_free_N10Ast__typ_t(&b_1);
            FX_COPY_PTR(*b0_1, &b_1);
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 16) {
         if (FX_REC_VARIANT_TAG(a_2) == 16) {
            _fx_N10Ast__typ_t* a0_2 = &a_2->u.TypVector;
            _fx_free_N10Ast__typ_t(&a_1);
            FX_COPY_PTR(*a0_2, &a_1);
            _fx_N10Ast__typ_t* b0_2 = &b_2->u.TypVector;
            _fx_free_N10Ast__typ_t(&b_1);
            FX_COPY_PTR(*b0_2, &b_1);
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 17) {
         if (FX_REC_VARIANT_TAG(a_2) == 17) {
            bool result_3;
            FX_CALL(_fx_M13Ast_typecheckFM6__eq__B2LN10Ast__typ_tLN10Ast__typ_t(a_2->u.TypTuple, b_2->u.TypTuple, &result_3, 0),
               _fx_catch_6);
            result_0 = result_3;
            FX_BREAK(_fx_catch_6);

         _fx_catch_6: ;
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 18) {
         if (FX_REC_VARIANT_TAG(a_2) == 18) {
            _fx_N10Ast__typ_t* a0_3 = &a_2->u.TypRef;
            _fx_free_N10Ast__typ_t(&a_1);
            FX_COPY_PTR(*a0_3, &a_1);
            _fx_N10Ast__typ_t* b0_3 = &b_2->u.TypRef;
            _fx_free_N10Ast__typ_t(&b_1);
            FX_COPY_PTR(*b0_3, &b_1);
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 19) {
         _fx_T2iN10Ast__typ_t* vcase_2 = &b_2->u.TypArray;
         if (FX_REC_VARIANT_TAG(a_2) == 19) {
            _fx_T2iN10Ast__typ_t* vcase_3 = &a_2->u.TypArray;
            bool v_2;
            FX_CALL(_fx_M13Ast_typecheckFM15__eq_variants__B2N10Ast__typ_tN10Ast__typ_t(vcase_3->t1, vcase_2->t1, &v_2, 0),
               _fx_catch_7);
            result_0 = (bool)((vcase_3->t0 == vcase_2->t0) & v_2);
            FX_BREAK(_fx_catch_7);

         _fx_catch_7: ;
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 20) {
         if (FX_REC_VARIANT_TAG(a_2) == 20) {
            bool result_4 =
               _fx_M13Ast_typecheckFM6__eq__B2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
                  a_2->u.TypRecord, b_2->u.TypRecord, 0);
            result_0 = result_4;
            FX_BREAK(_fx_catch_8);

         _fx_catch_8: ;
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(b_2) == 24) {
         _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_4 = &b_2->u.TypApp;
         if (FX_REC_VARIANT_TAG(a_2) == 24) {
            _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_5 = &a_2->u.TypApp;
            _fx_R9Ast__id_t* a1_0 = &vcase_5->t1;
            _fx_R9Ast__id_t* b1_0 = &vcase_4->t1;
            bool v_3;
            FX_CALL(_fx_M13Ast_typecheckFM6__eq__B2LN10Ast__typ_tLN10Ast__typ_t(vcase_5->t0, vcase_4->t0, &v_3, 0),
               _fx_catch_9);
            bool __fold_result___0 = true;
            bool t_0;
            if (a1_0->m == b1_0->m) {
               t_0 = __fold_result___0;
            }
            else {
               t_0 = false;
            }
            __fold_result___0 = t_0;
            bool t_1;
            if (a1_0->i == b1_0->i) {
               t_1 = __fold_result___0;
            }
            else {
               t_1 = false;
            }
            __fold_result___0 = t_1;
            bool t_2;
            if (a1_0->j == b1_0->j) {
               t_2 = __fold_result___0;
            }
            else {
               t_2 = false;
            }
            __fold_result___0 = t_2;
            result_0 = (bool)(v_3 & __fold_result___0);
            FX_BREAK(_fx_catch_9);

         _fx_catch_9: ;
            goto _fx_endmatch_0;
         }
      }
      result_0 = FX_REC_VARIANT_TAG(a_2) == FX_REC_VARIANT_TAG(b_2);
      FX_BREAK(_fx_catch_10);

   _fx_catch_10: ;

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_11);

   _fx_catch_11: ;
      if (b_2) {
         _fx_free_N10Ast__typ_t(&b_2);
      }
      if (a_2) {
         _fx_free_N10Ast__typ_t(&a_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = result_0;

_fx_cleanup: ;
   if (a_1) {
      _fx_free_N10Ast__typ_t(&a_1);
   }
   if (b_1) {
      _fx_free_N10Ast__typ_t(&b_1);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM15__eq_variants__B2N16Ast__env_entry_tN16Ast__env_entry_t(
   struct _fx_N16Ast__env_entry_t_data_t* a_0,
   struct _fx_N16Ast__env_entry_t_data_t* b_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (FX_REC_VARIANT_TAG(b_0) == 1) {
      if (FX_REC_VARIANT_TAG(a_0) == 1) {
         _fx_R9Ast__id_t* a0_0 = &a_0->u.EnvId;
         _fx_R9Ast__id_t* b0_0 = &b_0->u.EnvId;
         bool __fold_result___0 = true;
         bool t_0;
         if (a0_0->m == b0_0->m) {
            t_0 = __fold_result___0;
         }
         else {
            t_0 = false;
         }
         __fold_result___0 = t_0;
         bool t_1;
         if (a0_0->i == b0_0->i) {
            t_1 = __fold_result___0;
         }
         else {
            t_1 = false;
         }
         __fold_result___0 = t_1;
         bool t_2;
         if (a0_0->j == b0_0->j) {
            t_2 = __fold_result___0;
         }
         else {
            t_2 = false;
         }
         __fold_result___0 = t_2;
         *fx_result = __fold_result___0;
         goto _fx_endmatch_0;
      }
   }
   if (FX_REC_VARIANT_TAG(b_0) == 2) {
      if (FX_REC_VARIANT_TAG(a_0) == 2) {
         FX_CALL(
            _fx_M13Ast_typecheckFM15__eq_variants__B2N10Ast__typ_tN10Ast__typ_t(a_0->u.EnvTyp, b_0->u.EnvTyp, fx_result, 0),
            _fx_catch_0);

      _fx_catch_0: ;
         goto _fx_endmatch_0;
      }
   }
   *fx_result = FX_REC_VARIANT_TAG(a_0) == FX_REC_VARIANT_TAG(b_0);

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C bool _fx_M13Ast_typecheckFM8__same__B2LN10Ast__typ_tLN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* a,
   struct _fx_LN10Ast__typ_t_data_t* b,
   void* fx_fv)
{
   
return a == b;

}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3inti1l(int64_t x_0, int_* fx_result, void* fx_fv)
{
   int fx_status = 0;
   *fx_result = (int_)x_0;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM5printv1S(fx_str_t* a_0, void* fx_fv)
{
   int fx_status = 0;
   _fx_F12print_stringv1S(a_0, 0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM8length1_i1LT2R9Ast__id_tN10Ast__typ_t(
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* l_0,
   int_* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   *fx_result = _fx_M13Ast_typecheckFM6lengthi1LT2R9Ast__id_tN10Ast__typ_t(l_0, 0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM8length1_i1LN10Ast__pat_t(
   struct _fx_LN10Ast__pat_t_data_t* l_0,
   int_* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   *fx_result = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__pat_t(l_0, 0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM8length1_i1LT2N10Ast__exp_tB(
   struct _fx_LT2N10Ast__exp_tB_data_t* l_0,
   int_* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   *fx_result = _fx_M13Ast_typecheckFM6lengthi1LT2N10Ast__exp_tB(l_0, 0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM8length1_i1LN10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* l_0,
   int_* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   *fx_result = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__exp_t(l_0, 0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM8length1_i1LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* l_0,
   int_* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   *fx_result = _fx_M13Ast_typecheckFM6lengthi1LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(l_0, 0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* l_0,
   int_* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   *fx_result = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(l_0, 0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM2hdN10Ast__exp_t1LN10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* __pat___0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (__pat___0 != 0) {
      FX_COPY_PTR(__pat___0->hd, fx_result);
   }
   else {
      FX_FAST_THROW(FX_EXN_NullListError, _fx_cleanup);
   }

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM2tlLN10Ast__exp_t1LN10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* __pat___0,
   struct _fx_LN10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (__pat___0 != 0) {
      FX_COPY_PTR(__pat___0->tl, fx_result);
   }
   else {
      FX_FAST_THROW(FX_EXN_NullListError, _fx_cleanup);
   }

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM4lastN10Ast__exp_t1LN10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* __pat___0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__exp_t result_0 = 0;
   _fx_LN10Ast__exp_t __pat___1 = 0;
   int fx_status = 0;
   FX_COPY_PTR(__pat___0, &__pat___1);
   for (;;) {
      _fx_LN10Ast__exp_t __pat___2 = 0;
      FX_COPY_PTR(__pat___1, &__pat___2);
      if (__pat___2 != 0) {
         if (__pat___2->tl == 0) {
            _fx_N10Ast__exp_t result_1 = 0;
            FX_COPY_PTR(__pat___2->hd, &result_1);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_1, &result_0);
            FX_BREAK(_fx_catch_0);

         _fx_catch_0: ;
            if (result_1) {
               _fx_free_N10Ast__exp_t(&result_1);
            }
            goto _fx_endmatch_0;
         }
      }
      if (__pat___2 != 0) {
         _fx_LN10Ast__exp_t* rest_0 = &__pat___2->tl;
         _fx_free_LN10Ast__exp_t(&__pat___1);
         FX_COPY_PTR(*rest_0, &__pat___1);
         goto _fx_endmatch_0;
      }
      FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_1);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_1);

   _fx_catch_1: ;
      if (__pat___2) {
         _fx_free_LN10Ast__exp_t(&__pat___2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(result_0, fx_result);

_fx_cleanup: ;
   if (result_0) {
      _fx_free_N10Ast__exp_t(&result_0);
   }
   if (__pat___1) {
      _fx_free_LN10Ast__exp_t(&__pat___1);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM4lastN10Ast__typ_t1LN10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* __pat___0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t result_0 = 0;
   _fx_LN10Ast__typ_t __pat___1 = 0;
   int fx_status = 0;
   FX_COPY_PTR(__pat___0, &__pat___1);
   for (;;) {
      _fx_LN10Ast__typ_t __pat___2 = 0;
      FX_COPY_PTR(__pat___1, &__pat___2);
      if (__pat___2 != 0) {
         if (__pat___2->tl == 0) {
            _fx_N10Ast__typ_t result_1 = 0;
            FX_COPY_PTR(__pat___2->hd, &result_1);
            _fx_free_N10Ast__typ_t(&result_0);
            FX_COPY_PTR(result_1, &result_0);
            FX_BREAK(_fx_catch_0);

         _fx_catch_0: ;
            if (result_1) {
               _fx_free_N10Ast__typ_t(&result_1);
            }
            goto _fx_endmatch_0;
         }
      }
      if (__pat___2 != 0) {
         _fx_LN10Ast__typ_t* rest_0 = &__pat___2->tl;
         _fx_free_LN10Ast__typ_t(&__pat___1);
         FX_COPY_PTR(*rest_0, &__pat___1);
         goto _fx_endmatch_0;
      }
      FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_1);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_1);

   _fx_catch_1: ;
      if (__pat___2) {
         _fx_free_LN10Ast__typ_t(&__pat___2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(result_0, fx_result);

_fx_cleanup: ;
   if (result_0) {
      _fx_free_N10Ast__typ_t(&result_0);
   }
   if (__pat___1) {
      _fx_free_LN10Ast__typ_t(&__pat___1);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3nthN10Ast__typ_t2LN10Ast__typ_ti(
   struct _fx_LN10Ast__typ_t_data_t* l_0,
   int_ n_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t result_0 = 0;
   _fx_LN10Ast__typ_t l_1 = 0;
   int fx_status = 0;
   FX_COPY_PTR(l_0, &l_1);
   int_ n_1 = n_0;
   for (;;) {
      _fx_LN10Ast__typ_t l_2 = 0;
      FX_COPY_PTR(l_1, &l_2);
      int_ n_2 = n_1;
      if (l_2 != 0) {
         if (n_2 == 0) {
            _fx_N10Ast__typ_t* a_0 = &l_2->hd;
            _fx_free_N10Ast__typ_t(&result_0);
            FX_COPY_PTR(*a_0, &result_0);
            FX_BREAK(_fx_catch_0);
         }
         else {
            _fx_LN10Ast__typ_t* rest_0 = &l_2->tl; _fx_free_LN10Ast__typ_t(&l_1); FX_COPY_PTR(*rest_0, &l_1); n_1 = n_2 - 1;
         }

      _fx_catch_0: ;
      }
      else {
         FX_FAST_THROW(FX_EXN_OutOfRangeError, _fx_catch_1);
      }
      FX_CHECK_EXN(_fx_catch_1);

   _fx_catch_1: ;
      if (l_2) {
         _fx_free_LN10Ast__typ_t(&l_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(result_0, fx_result);

_fx_cleanup: ;
   if (result_0) {
      _fx_free_N10Ast__typ_t(&result_0);
   }
   if (l_1) {
      _fx_free_LN10Ast__typ_t(&l_1);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM3revLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t1LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t* l_0,
   struct _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t __fold_result___0 = 0;
   int fx_status = 0;
   _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t r_0 = 0;
      _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t* a_0 = &lst_0->hd;
      FX_COPY_PTR(__fold_result___0, &r_0);
      FX_CALL(_fx_cons_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(a_0, r_0, false, &r_0), _fx_catch_0);
      _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&__fold_result___0);
      FX_COPY_PTR(r_0, &__fold_result___0);

   _fx_catch_0: ;
      if (r_0) {
         _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___0, fx_result);

_fx_cleanup: ;
   if (__fold_result___0) {
      _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&__fold_result___0);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3revLT2R9Ast__id_tN10Ast__pat_t1LT2R9Ast__id_tN10Ast__pat_t(
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t* l_0,
   struct _fx_LT2R9Ast__id_tN10Ast__pat_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LT2R9Ast__id_tN10Ast__pat_t __fold_result___0 = 0;
   int fx_status = 0;
   _fx_LT2R9Ast__id_tN10Ast__pat_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_LT2R9Ast__id_tN10Ast__pat_t r_0 = 0;
      _fx_T2R9Ast__id_tN10Ast__pat_t* a_0 = &lst_0->hd;
      FX_COPY_PTR(__fold_result___0, &r_0);
      FX_CALL(_fx_cons_LT2R9Ast__id_tN10Ast__pat_t(a_0, r_0, false, &r_0), _fx_catch_0);
      _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&__fold_result___0);
      FX_COPY_PTR(r_0, &__fold_result___0);

   _fx_catch_0: ;
      if (r_0) {
         _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___0, fx_result);

_fx_cleanup: ;
   if (__fold_result___0) {
      _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&__fold_result___0);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3revLT2N10Ast__pat_tN10Ast__exp_t1LT2N10Ast__pat_tN10Ast__exp_t(
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* l_0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LT2N10Ast__pat_tN10Ast__exp_t __fold_result___0 = 0;
   int fx_status = 0;
   _fx_LT2N10Ast__pat_tN10Ast__exp_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_LT2N10Ast__pat_tN10Ast__exp_t r_0 = 0;
      _fx_T2N10Ast__pat_tN10Ast__exp_t* a_0 = &lst_0->hd;
      FX_COPY_PTR(__fold_result___0, &r_0);
      FX_CALL(_fx_cons_LT2N10Ast__pat_tN10Ast__exp_t(a_0, r_0, false, &r_0), _fx_catch_0);
      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&__fold_result___0);
      FX_COPY_PTR(r_0, &__fold_result___0);

   _fx_catch_0: ;
      if (r_0) {
         _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___0, fx_result);

_fx_cleanup: ;
   if (__fold_result___0) {
      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&__fold_result___0);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3revLLN10Ast__exp_t1LLN10Ast__exp_t(
   struct _fx_LLN10Ast__exp_t_data_t* l_0,
   struct _fx_LLN10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LLN10Ast__exp_t __fold_result___0 = 0;
   int fx_status = 0;
   _fx_LLN10Ast__exp_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_LLN10Ast__exp_t r_0 = 0;
      _fx_LN10Ast__exp_t a_0 = lst_0->hd;
      FX_COPY_PTR(__fold_result___0, &r_0);
      FX_CALL(_fx_cons_LLN10Ast__exp_t(a_0, r_0, false, &r_0), _fx_catch_0);
      _fx_free_LLN10Ast__exp_t(&__fold_result___0);
      FX_COPY_PTR(r_0, &__fold_result___0);

   _fx_catch_0: ;
      if (r_0) {
         _fx_free_LLN10Ast__exp_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___0, fx_result);

_fx_cleanup: ;
   if (__fold_result___0) {
      _fx_free_LLN10Ast__exp_t(&__fold_result___0);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3revLN10Ast__exp_t1LN10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* l_0,
   struct _fx_LN10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LN10Ast__exp_t __fold_result___0 = 0;
   int fx_status = 0;
   _fx_LN10Ast__exp_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_LN10Ast__exp_t r_0 = 0;
      _fx_N10Ast__exp_t a_0 = lst_0->hd;
      FX_COPY_PTR(__fold_result___0, &r_0);
      FX_CALL(_fx_cons_LN10Ast__exp_t(a_0, r_0, false, &r_0), _fx_catch_0);
      _fx_free_LN10Ast__exp_t(&__fold_result___0);
      FX_COPY_PTR(r_0, &__fold_result___0);

   _fx_catch_0: ;
      if (r_0) {
         _fx_free_LN10Ast__exp_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___0, fx_result);

_fx_cleanup: ;
   if (__fold_result___0) {
      _fx_free_LN10Ast__exp_t(&__fold_result___0);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3revLN10Ast__pat_t1LN10Ast__pat_t(
   struct _fx_LN10Ast__pat_t_data_t* l_0,
   struct _fx_LN10Ast__pat_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LN10Ast__pat_t __fold_result___0 = 0;
   int fx_status = 0;
   _fx_LN10Ast__pat_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_LN10Ast__pat_t r_0 = 0;
      _fx_N10Ast__pat_t a_0 = lst_0->hd;
      FX_COPY_PTR(__fold_result___0, &r_0);
      FX_CALL(_fx_cons_LN10Ast__pat_t(a_0, r_0, false, &r_0), _fx_catch_0);
      _fx_free_LN10Ast__pat_t(&__fold_result___0);
      FX_COPY_PTR(r_0, &__fold_result___0);

   _fx_catch_0: ;
      if (r_0) {
         _fx_free_LN10Ast__pat_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___0, fx_result);

_fx_cleanup: ;
   if (__fold_result___0) {
      _fx_free_LN10Ast__pat_t(&__fold_result___0);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM9assoc_optNt6option1N10Ast__typ_t2LT2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(
   struct _fx_LT2R9Ast__id_tN10Ast__typ_t_data_t* l_0,
   struct _fx_R9Ast__id_t* x_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t __fold_result___0 = {0};
   _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t __fold_result___1 = {0};
   int fx_status = 0;
   _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, &__fold_result___0);
   _fx_LT2R9Ast__id_tN10Ast__typ_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t v_0 = {0};
      _fx_T2R9Ast__id_tN10Ast__typ_t* __pat___0 = &lst_0->hd;
      _fx_R9Ast__id_t a_0 = __pat___0->t0;
      bool __fold_result___2 = true;
      bool t_0;
      if (a_0.m == x_0->m) {
         t_0 = __fold_result___2;
      }
      else {
         t_0 = false;
      }
      __fold_result___2 = t_0;
      bool t_1;
      if (a_0.i == x_0->i) {
         t_1 = __fold_result___2;
      }
      else {
         t_1 = false;
      }
      __fold_result___2 = t_1;
      bool t_2;
      if (a_0.j == x_0->j) {
         t_2 = __fold_result___2;
      }
      else {
         t_2 = false;
      }
      __fold_result___2 = t_2;
      if (__fold_result___2) {
         _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(__pat___0, &v_0);
         _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&__fold_result___0);
         _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_0, &__fold_result___0);
         FX_BREAK(_fx_catch_0);
      }

   _fx_catch_0: ;
      _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_0);
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&__fold_result___0, &__fold_result___1);
   if (__fold_result___1.tag == 2) {
      FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(__fold_result___1.u.Some.t1, fx_result),
         _fx_catch_1);

   _fx_catch_1: ;
   }
   else {
      FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, fx_result);
   }

_fx_cleanup: ;
   _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&__fold_result___0);
   _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&__fold_result___1);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3mapLN10Ast__typ_t2LN10Ast__exp_tFPN10Ast__typ_t1N10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* l_0,
   struct _fx_FPN10Ast__typ_t1N10Ast__exp_t* f_0,
   struct _fx_LN10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_LN10Ast__typ_t lstend_0 = 0;
   _fx_LN10Ast__exp_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__typ_t res_0 = 0;
      _fx_N10Ast__exp_t x_0 = lst_0->hd;
      FX_CALL(f_0->fp(x_0, &res_0, f_0->fcv), _fx_catch_0);
      _fx_LN10Ast__typ_t node_0 = 0;
      FX_CALL(_fx_cons_LN10Ast__typ_t(res_0, 0, false, &node_0), _fx_catch_0);
      FX_LIST_APPEND(*fx_result, lstend_0, node_0);

   _fx_catch_0: ;
      if (res_0) {
         _fx_free_N10Ast__typ_t(&res_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3mapLN10Ast__exp_t2LN10Ast__exp_tFPN10Ast__exp_t1N10Ast__exp_t(
   struct _fx_LN10Ast__exp_t_data_t* l_0,
   struct _fx_FPN10Ast__exp_t1N10Ast__exp_t* f_0,
   struct _fx_LN10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_LN10Ast__exp_t lstend_0 = 0;
   _fx_LN10Ast__exp_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__exp_t res_0 = 0;
      _fx_N10Ast__exp_t x_0 = lst_0->hd;
      FX_CALL(f_0->fp(x_0, &res_0, f_0->fcv), _fx_catch_0);
      _fx_LN10Ast__exp_t node_0 = 0;
      FX_CALL(_fx_cons_LN10Ast__exp_t(res_0, 0, false, &node_0), _fx_catch_0);
      FX_LIST_APPEND(*fx_result, lstend_0, node_0);

   _fx_catch_0: ;
      if (res_0) {
         _fx_free_N10Ast__exp_t(&res_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3allB2LN10Ast__typ_tFPB1N10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* l_0,
   struct _fx_FPB1N10Ast__typ_t* f_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   bool __fold_result___0 = true;
   _fx_LN10Ast__typ_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__typ_t a_0 = lst_0->hd;
      bool v_0;
      FX_CALL(f_0->fp(a_0, &v_0, f_0->fcv), _fx_catch_0);
      if (!v_0) {
         __fold_result___0 = false; FX_BREAK(_fx_catch_0);
      }

   _fx_catch_0: ;
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = __fold_result___0;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM8find_optNt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tFPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* l_0,
   struct _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* f_0,
   struct _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result,
   void* fx_fv)
{
   _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t __fold_result___0 = {0};
   int fx_status = 0;
   _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&_fx_g21Ast_typecheck__None1_,
      &__fold_result___0);
   _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_0 = l_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_0 = {0};
      _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* a_0 = &lst_0->hd;
      bool v_1;
      FX_CALL(f_0->fp(a_0, &v_1, f_0->fcv), _fx_catch_0);
      if (v_1) {
         _fx_M13Ast_typecheckFM4SomeNt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
            a_0, &v_0);
         _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___0);
         _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_0, &__fold_result___0);
         FX_BREAK(_fx_catch_0);
      }

   _fx_catch_0: ;
      _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_0);
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___0, fx_result);

_fx_cleanup: ;
   _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___0);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9add_fast_i4iA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_tRt24Hashset__hashset_entry_t1R9Ast__id_t(
   int_ tabsz_0,
   fx_arr_t* ht_index_0,
   fx_arr_t* ht_table_0,
   struct _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t* entry_0,
   int_* fx_result,
   void* fx_fv)
{
   fx_exn_t v_0 = {0};
   int fx_status = 0;
   int_ idxsz_0 = FX_ARR_SIZE(*ht_index_0, 0);
   uint64_t hv_0 = entry_0->hv;
   uint64_t perturb_0 = hv_0;
   int_ j_0 = (int_)hv_0 & (idxsz_0 - 1);
   bool found_free_slot_0 = false;
   int_ v_1 = idxsz_0 + 14;
   for (int_ i_0 = 0; i_0 < v_1; i_0++) {
      FX_CHKIDX(FX_CHKIDX1(*ht_index_0, 0, j_0), _fx_catch_0);
      int_ tidx_0 = *FX_PTR_1D(int_, *ht_index_0, j_0);
      if (tidx_0 == 0) {
         FX_CHKIDX(FX_CHKIDX1(*ht_index_0, 0, j_0), _fx_catch_0);
         *FX_PTR_1D(int_, *ht_index_0, j_0) = tabsz_0 + 2;
         FX_CHKIDX(FX_CHKIDX1(*ht_table_0, 0, tabsz_0), _fx_catch_0);
         *FX_PTR_1D(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t, *ht_table_0, tabsz_0) = *entry_0;
         found_free_slot_0 = true;
         FX_BREAK(_fx_catch_0);
      }
      perturb_0 = perturb_0 >> 5;
      j_0 = (int_)((uint64_t)(j_0 * 5 + 1) + perturb_0) & (idxsz_0 - 1);

   _fx_catch_0: ;
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   if (!found_free_slot_0) {
      fx_str_t slit_0 = FX_MAKE_STR("cannot insert element (full Hashtable?!)");
      FX_CALL(_fx_F9make_FailE1S(&slit_0, &v_0), _fx_cleanup);
      FX_THROW(&v_0, true, _fx_cleanup);
   }
   *fx_result = tabsz_0 + 1;

_fx_cleanup: ;
   fx_free_exn(&v_0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM4growv2Nt10Hashset__t1R9Ast__id_ti(
   struct _fx_Nt10Hashset__t1R9Ast__id_t_data_t* self_0,
   int_ new_size_0,
   void* fx_fv)
{
   fx_arr_t ht_table_0 = {0};
   fx_arr_t new_ht_table_0 = {0};
   fx_arr_t new_ht_index_0 = {0};
   int fx_status = 0;
   fx_copy_arr(&self_0->u.t.t5, &ht_table_0);
   _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t v_0 = self_0->u.t.t0;
   _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t* dstptr_0 = 0;
   {
      const int_ shape_0[] = { new_size_0 };
      FX_CALL(fx_make_arr(1, shape_0, sizeof(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t), 0, 0, 0, &new_ht_table_0),
         _fx_cleanup);
   }
   dstptr_0 = (_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t*)new_ht_table_0.data;
   for (int_ i_0 = 0; i_0 < new_size_0; i_0++, dstptr_0++) {
      *dstptr_0 = v_0;
   }
   FX_CALL(_fx_M7HashsetFM9makeindexA1i1i(new_size_0 * 2, &new_ht_index_0, 0), _fx_cleanup);
   int_ tabsz_0 = 0;
   int_ v_1 = self_0->u.t.t2;
   for (int_ j_0 = 0; j_0 < v_1; j_0++) {
      FX_CHKIDX(FX_CHKIDX1(ht_table_0, 0, j_0), _fx_catch_0);
      if (FX_PTR_1D(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t, ht_table_0, j_0)->hv < 9223372036854775808ULL) {
         FX_CHKIDX(FX_CHKIDX1(ht_table_0, 0, j_0), _fx_catch_0);
         _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t v_2 =
            *FX_PTR_1D(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t, ht_table_0, j_0);
         int_ v_3;
         FX_CALL(
            _fx_M13Ast_typecheckFM9add_fast_i4iA1iA1Rt24Hashset__hashset_entry_t1R9Ast__id_tRt24Hashset__hashset_entry_t1R9Ast__id_t(
               tabsz_0, &new_ht_index_0, &new_ht_table_0, &v_2, &v_3, 0), _fx_catch_0);
         tabsz_0 = v_3;
      }

   _fx_catch_0: ;
      FX_CHECK_EXN(_fx_cleanup);
   }
   fx_arr_t* v_4 = &self_0->u.t.t4;
   FX_FREE_ARR(v_4);
   fx_copy_arr(&new_ht_index_0, v_4);
   fx_arr_t* v_5 = &self_0->u.t.t5;
   FX_FREE_ARR(v_5);
   fx_copy_arr(&new_ht_table_0, v_5);
   self_0->u.t.t2 = tabsz_0;
   self_0->u.t.t3 = 0;

_fx_cleanup: ;
   FX_FREE_ARR(&ht_table_0);
   FX_FREE_ARR(&new_ht_table_0);
   FX_FREE_ARR(&new_ht_index_0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM4add_v3Nt10Hashset__t1R9Ast__id_tR9Ast__id_tq(
   struct _fx_Nt10Hashset__t1R9Ast__id_t_data_t* self_0,
   struct _fx_R9Ast__id_t* k_0,
   uint64_t hv_0,
   void* fx_fv)
{
   fx_arr_t v_0 = {0};
   fx_arr_t v_1 = {0};
   fx_exn_t v_2 = {0};
   int fx_status = 0;
   fx_copy_arr(&self_0->u.t.t4, &v_0);
   int_ idxsz_0 = FX_ARR_SIZE(v_0, 0);
   if (self_0->u.t.t1 + 1 > idxsz_0 >> 1) {
      while (idxsz_0 < (self_0->u.t.t1 + 1) * 2) {
         idxsz_0 = idxsz_0 * 2;
      }
      FX_CALL(_fx_M13Ast_typecheckFM4growv2Nt10Hashset__t1R9Ast__id_ti(self_0, fx_maxi(idxsz_0 / 2, self_0->u.t.t1 + 1), 0),
         _fx_cleanup);
   }
   uint64_t perturb_0 = hv_0;
   int_ found_0 = -1;
   int_ insert_idx_0 = -1;
   int_ j_0 = (int_)hv_0 & (idxsz_0 - 1);
   int_ v_3 = idxsz_0 + 14;
   for (int_ i_0 = 0; i_0 < v_3; i_0++) {
      FX_CHKIDX(FX_CHKIDX1(self_0->u.t.t4, 0, j_0), _fx_catch_0);
      int_ tidx_0 = *FX_PTR_1D(int_, self_0->u.t.t4, j_0);
      if (tidx_0 >= 2) {
         int_ v_4 = tidx_0 - 2;
         FX_CHKIDX(FX_CHKIDX1(self_0->u.t.t5, 0, v_4), _fx_catch_0);
         _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t entry_0 =
            *FX_PTR_1D(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t, self_0->u.t.t5, v_4);
         bool t_0;
         if (entry_0.hv == hv_0) {
            _fx_R9Ast__id_t v_5 = entry_0.key;
            bool __fold_result___0 = true;
            bool t_1;
            if (v_5.m == k_0->m) {
               t_1 = __fold_result___0;
            }
            else {
               t_1 = false;
            }
            __fold_result___0 = t_1;
            bool t_2;
            if (v_5.i == k_0->i) {
               t_2 = __fold_result___0;
            }
            else {
               t_2 = false;
            }
            __fold_result___0 = t_2;
            bool t_3;
            if (v_5.j == k_0->j) {
               t_3 = __fold_result___0;
            }
            else {
               t_3 = false;
            }
            __fold_result___0 = t_3;
            t_0 = __fold_result___0;
         }
         else {
            t_0 = false;
         }
         if (t_0) {
            found_0 = tidx_0 - 2; FX_BREAK(_fx_catch_0);
         }
      }
      else if (tidx_0 == 0) {
         if (insert_idx_0 < 0) {
            insert_idx_0 = j_0;
         }
         FX_BREAK(_fx_catch_0);
      }
      else {
         bool t_4;
         if (tidx_0 == 1) {
            t_4 = insert_idx_0 < 0;
         }
         else {
            t_4 = false;
         }
         if (t_4) {
            insert_idx_0 = j_0;
         }
      }
      perturb_0 = perturb_0 >> 5;
      j_0 = (int_)((uint64_t)(j_0 * 5 + 1) + perturb_0) & (idxsz_0 - 1);

   _fx_catch_0: ;
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   if (found_0 >= 0) {
      bool t_5;
      if (insert_idx_0 >= 0) {
         t_5 = insert_idx_0 != j_0;
      }
      else {
         t_5 = false;
      }
      if (t_5) {
         FX_CHKIDX(FX_CHKIDX1(self_0->u.t.t4, 0, insert_idx_0), _fx_cleanup);
         *FX_PTR_1D(int_, self_0->u.t.t4, insert_idx_0) = found_0 + 2;
         FX_CHKIDX(FX_CHKIDX1(self_0->u.t.t4, 0, j_0), _fx_cleanup);
         *FX_PTR_1D(int_, self_0->u.t.t4, j_0) = 1;
      }
   }
   else if (insert_idx_0 >= 0) {
      found_0 = self_0->u.t.t3 - 1;
      if (found_0 >= 0) {
         FX_CHKIDX(FX_CHKIDX1(self_0->u.t.t5, 0, found_0), _fx_cleanup);
         self_0->u.t.t3 =
            (int_)
               (FX_PTR_1D(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t, self_0->u.t.t5, found_0)->hv & 9223372036854775807ULL);
      }
      else {
         found_0 = self_0->u.t.t2;
         self_0->u.t.t2 = self_0->u.t.t2 + 1;
         fx_copy_arr(&self_0->u.t.t5, &v_1);
         FX_CALL(_fx_F6assertv1B(found_0 < FX_ARR_SIZE(v_1, 0), 0), _fx_cleanup);
      }
      _fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t v_6 = { hv_0, *k_0 };
      FX_CHKIDX(FX_CHKIDX1(self_0->u.t.t5, 0, found_0), _fx_cleanup);
      *FX_PTR_1D(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t, self_0->u.t.t5, found_0) = v_6;
      FX_CHKIDX(FX_CHKIDX1(self_0->u.t.t4, 0, insert_idx_0), _fx_cleanup);
      *FX_PTR_1D(int_, self_0->u.t.t4, insert_idx_0) = found_0 + 2;
      self_0->u.t.t1 = self_0->u.t.t1 + 1;
   }
   else {
      fx_str_t slit_0 = FX_MAKE_STR("cannot insert element (full Hashtable?!)");
      FX_CALL(_fx_F9make_FailE1S(&slit_0, &v_2), _fx_cleanup);
      FX_THROW(&v_2, true, _fx_cleanup);
   }

_fx_cleanup: ;
   FX_FREE_ARR(&v_0);
   FX_FREE_ARR(&v_1);
   fx_free_exn(&v_2);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3addv2Nt10Hashset__t1R9Ast__id_tR9Ast__id_t(
   struct _fx_Nt10Hashset__t1R9Ast__id_t_data_t* self_0,
   struct _fx_R9Ast__id_t* k_0,
   void* fx_fv)
{
   int fx_status = 0;
   uint64_t __fold_result___0 = 14695981039346656037ULL;
   uint64_t h_0 = __fold_result___0 ^ ((uint64_t)k_0->m ^ 14695981039346656037ULL);
   __fold_result___0 = h_0 * 1099511628211ULL;
   uint64_t h_1 = __fold_result___0 ^ ((uint64_t)k_0->i ^ 14695981039346656037ULL);
   __fold_result___0 = h_1 * 1099511628211ULL;
   uint64_t h_2 = __fold_result___0 ^ ((uint64_t)k_0->j ^ 14695981039346656037ULL);
   __fold_result___0 = h_2 * 1099511628211ULL;
   FX_CALL(
      _fx_M13Ast_typecheckFM4add_v3Nt10Hashset__t1R9Ast__id_tR9Ast__id_tq(self_0, k_0,
         __fold_result___0 & 9223372036854775807ULL, 0), _fx_cleanup);

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
   struct _fx_N12Map__color_t* arg0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* arg1,
   struct _fx_R9Ast__id_t* arg2,
   struct _fx_R9Ast__id_t* arg3,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* arg4,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t** fx_result)
{
   FX_MAKE_RECURSIVE_VARIANT_IMPL_START(_fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t);
   v->u.Node.t0 = *arg0;
   FX_COPY_PTR(arg1, &v->u.Node.t1);
   v->u.Node.t2 = *arg2;
   v->u.Node.t3 = *arg3;
   FX_COPY_PTR(arg4, &v->u.Node.t4);
   return 0;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_N12Map__color_t* arg0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* arg1,
   struct _fx_R9Ast__id_t* arg2,
   struct _fx_LN16Ast__env_entry_t_data_t* arg3,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* arg4,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t** fx_result)
{
   FX_MAKE_RECURSIVE_VARIANT_IMPL_START(_fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t);
   v->u.Node.t0 = *arg0;
   FX_COPY_PTR(arg1, &v->u.Node.t1);
   v->u.Node.t2 = *arg2;
   FX_COPY_PTR(arg3, &v->u.Node.t3);
   FX_COPY_PTR(arg4, &v->u.Node.t4);
   return 0;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12balance_leftNt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* l_0,
   struct _fx_R9Ast__id_t* xk_0,
   struct _fx_R9Ast__id_t* xd_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* r_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if ((l_0 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
         vcase_0 = &l_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_0 = vcase_0->t1;
         if ((v_0 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
               vcase_1 = &v_0->u.Node;
            if (vcase_1->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_1 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_2 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g20Ast_typecheck__Black, vcase_1->t1, &vcase_1->t2, &vcase_1->t3, vcase_1->t4, &v_1), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g20Ast_typecheck__Black, vcase_0->t4, xk_0, xd_0, r_0, &v_2), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g18Ast_typecheck__Red, v_1, &vcase_0->t2, &vcase_0->t3, v_2, fx_result), _fx_catch_0);

            _fx_catch_0: ;
               if (v_2) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_2);
               }
               if (v_1) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_1);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   if ((l_0 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
         vcase_2 = &l_0->u.Node;
      if (vcase_2->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_3 = vcase_2->t4;
         if ((v_3 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
               vcase_3 = &v_3->u.Node;
            if (vcase_3->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_4 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_5 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g20Ast_typecheck__Black, vcase_2->t1, &vcase_2->t2, &vcase_2->t3, vcase_3->t1, &v_4), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g20Ast_typecheck__Black, vcase_3->t4, xk_0, xd_0, r_0, &v_5), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g18Ast_typecheck__Red, v_4, &vcase_3->t2, &vcase_3->t3, v_5, fx_result), _fx_catch_1);

            _fx_catch_1: ;
               if (v_5) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_5);
               }
               if (v_4) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_4);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
         &_fx_g20Ast_typecheck__Black, l_0, xk_0, xd_0, r_0, fx_result), _fx_catch_2);

_fx_catch_2: ;

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12balance_leftNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* l_0,
   struct _fx_R9Ast__id_t* xk_0,
   struct _fx_LN16Ast__env_entry_t_data_t* xd_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* r_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if ((l_0 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_0 = &l_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_0 = vcase_0->t1;
         if ((v_0 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
               vcase_1 = &v_0->u.Node;
            if (vcase_1->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_1 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_2 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, vcase_1->t1, &vcase_1->t2, vcase_1->t3, vcase_1->t4, &v_1), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, vcase_0->t4, xk_0, xd_0, r_0, &v_2), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g18Ast_typecheck__Red, v_1, &vcase_0->t2, vcase_0->t3, v_2, fx_result), _fx_catch_0);

            _fx_catch_0: ;
               if (v_2) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
               }
               if (v_1) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_1);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   if ((l_0 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_2 = &l_0->u.Node;
      if (vcase_2->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_3 = vcase_2->t4;
         if ((v_3 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
               vcase_3 = &v_3->u.Node;
            if (vcase_3->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_4 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_5 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, vcase_2->t1, &vcase_2->t2, vcase_2->t3, vcase_3->t1, &v_4), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, vcase_3->t4, xk_0, xd_0, r_0, &v_5), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g18Ast_typecheck__Red, v_4, &vcase_3->t2, vcase_3->t3, v_5, fx_result), _fx_catch_1);

            _fx_catch_1: ;
               if (v_5) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_5);
               }
               if (v_4) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
         &_fx_g20Ast_typecheck__Black, l_0, xk_0, xd_0, r_0, fx_result), _fx_catch_2);

_fx_catch_2: ;

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM13balance_rightNt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* l_0,
   struct _fx_R9Ast__id_t* xk_0,
   struct _fx_R9Ast__id_t* xd_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* r_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if ((r_0 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
         vcase_0 = &r_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_0 = vcase_0->t1;
         if ((v_0 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
               vcase_1 = &v_0->u.Node;
            if (vcase_1->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_1 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_2 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g20Ast_typecheck__Black, l_0, xk_0, xd_0, vcase_1->t1, &v_1), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g20Ast_typecheck__Black, vcase_1->t4, &vcase_0->t2, &vcase_0->t3, vcase_0->t4, &v_2), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g18Ast_typecheck__Red, v_1, &vcase_1->t2, &vcase_1->t3, v_2, fx_result), _fx_catch_0);

            _fx_catch_0: ;
               if (v_2) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_2);
               }
               if (v_1) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_1);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   if ((r_0 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
         vcase_2 = &r_0->u.Node;
      if (vcase_2->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_3 = vcase_2->t4;
         if ((v_3 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
               vcase_3 = &v_3->u.Node;
            if (vcase_3->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_4 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_5 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g20Ast_typecheck__Black, l_0, xk_0, xd_0, vcase_2->t1, &v_4), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g20Ast_typecheck__Black, vcase_3->t1, &vcase_3->t2, &vcase_3->t3, vcase_3->t4, &v_5), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                     &_fx_g18Ast_typecheck__Red, v_4, &vcase_2->t2, &vcase_2->t3, v_5, fx_result), _fx_catch_1);

            _fx_catch_1: ;
               if (v_5) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_5);
               }
               if (v_4) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_4);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
         &_fx_g20Ast_typecheck__Black, l_0, xk_0, xd_0, r_0, fx_result), _fx_catch_2);

_fx_catch_2: ;

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM13balance_rightNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* l_0,
   struct _fx_R9Ast__id_t* xk_0,
   struct _fx_LN16Ast__env_entry_t_data_t* xd_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* r_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if ((r_0 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_0 = &r_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_0 = vcase_0->t1;
         if ((v_0 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
               vcase_1 = &v_0->u.Node;
            if (vcase_1->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_1 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_2 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, l_0, xk_0, xd_0, vcase_1->t1, &v_1), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, vcase_1->t4, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_2), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g18Ast_typecheck__Red, v_1, &vcase_1->t2, vcase_1->t3, v_2, fx_result), _fx_catch_0);

            _fx_catch_0: ;
               if (v_2) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
               }
               if (v_1) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_1);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   if ((r_0 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_2 = &r_0->u.Node;
      if (vcase_2->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_3 = vcase_2->t4;
         if ((v_3 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
               vcase_3 = &v_3->u.Node;
            if (vcase_3->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_4 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_5 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, l_0, xk_0, xd_0, vcase_2->t1, &v_4), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, vcase_3->t1, &vcase_3->t2, vcase_3->t3, vcase_3->t4, &v_5), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g18Ast_typecheck__Red, v_4, &vcase_2->t2, vcase_2->t3, v_5, fx_result), _fx_catch_1);

            _fx_catch_1: ;
               if (v_5) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_5);
               }
               if (v_4) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
         &_fx_g20Ast_typecheck__Black, l_0, xk_0, xd_0, r_0, fx_result), _fx_catch_2);

_fx_catch_2: ;

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t* t_0,
   struct _fx_R9Ast__id_t* xk_0,
   struct _fx_R9Ast__id_t* xd_0,
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t* cmp_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int tag_0 = (t_0 != 0) + 1;
   if (tag_0 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
         vcase_0 = &t_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_0 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_1 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t r_0 = vcase_0->t4;
         _fx_R9Ast__id_t* yd_0 = &vcase_0->t3;
         _fx_R9Ast__id_t* yk_0 = &vcase_0->t2;
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t l_0 = vcase_0->t1;
         int_ c_0;
         FX_CALL(cmp_0->fp(xk_0, yk_0, &c_0, cmp_0->fcv), _fx_catch_0);
         if (c_0 < 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  l_0, xk_0, xd_0, cmp_0, &v_0, 0), _fx_catch_0);
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                  &_fx_g18Ast_typecheck__Red, v_0, yk_0, yd_0, r_0, fx_result), _fx_catch_0);
         }
         else if (c_0 > 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  r_0, xk_0, xd_0, cmp_0, &v_1, 0), _fx_catch_0);
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                  &_fx_g18Ast_typecheck__Red, l_0, yk_0, yd_0, v_1, fx_result), _fx_catch_0);
         }
         else {
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                  &_fx_g18Ast_typecheck__Red, l_0, xk_0, xd_0, r_0, fx_result), _fx_catch_0);
         }

      _fx_catch_0: ;
         if (v_1) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_1);
         }
         if (v_0) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_0);
         }
         goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
         vcase_1 = &t_0->u.Node;
      if (vcase_1->t0.tag == 2) {
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_2 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_3 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t r_1 = vcase_1->t4;
         _fx_R9Ast__id_t* yd_1 = &vcase_1->t3;
         _fx_R9Ast__id_t* yk_1 = &vcase_1->t2;
         _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t l_1 = vcase_1->t1;
         int_ c_1;
         FX_CALL(cmp_0->fp(xk_0, yk_1, &c_1, cmp_0->fcv), _fx_catch_1);
         if (c_1 < 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  l_1, xk_0, xd_0, cmp_0, &v_2, 0), _fx_catch_1);
            FX_CALL(
               _fx_M13Ast_typecheckFM12balance_leftNt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                  v_2, yk_1, yd_1, r_1, fx_result, 0), _fx_catch_1);
         }
         else if (c_1 > 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  r_1, xk_0, xd_0, cmp_0, &v_3, 0), _fx_catch_1);
            FX_CALL(
               _fx_M13Ast_typecheckFM13balance_rightNt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                  l_1, yk_1, yd_1, v_3, fx_result, 0), _fx_catch_1);
         }
         else {
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                  &_fx_g20Ast_typecheck__Black, l_1, xk_0, xd_0, r_1, fx_result), _fx_catch_1);
         }

      _fx_catch_1: ;
         if (v_3) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_3);
         }
         if (v_2) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_2);
         }
         goto _fx_endmatch_0;
      }
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
         &_fx_g18Ast_typecheck__Red, _fx_g20Ast_typecheck__Empty, xk_0, xd_0, _fx_g20Ast_typecheck__Empty, fx_result),
      _fx_catch_2);

_fx_catch_2: ;

_fx_endmatch_0: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t_0,
   struct _fx_R9Ast__id_t* xk_0,
   struct _fx_LN16Ast__env_entry_t_data_t* xd_0,
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t* cmp_0,
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int tag_0 = (t_0 != 0) + 1;
   if (tag_0 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_0 = &t_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_0 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_1 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t r_0 = vcase_0->t4;
         _fx_LN16Ast__env_entry_t yd_0 = vcase_0->t3;
         _fx_R9Ast__id_t* yk_0 = &vcase_0->t2;
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t l_0 = vcase_0->t1;
         int_ c_0;
         FX_CALL(cmp_0->fp(xk_0, yk_0, &c_0, cmp_0->fcv), _fx_catch_0);
         if (c_0 < 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
                  l_0, xk_0, xd_0, cmp_0, &v_0, 0), _fx_catch_0);
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  &_fx_g18Ast_typecheck__Red, v_0, yk_0, yd_0, r_0, fx_result), _fx_catch_0);
         }
         else if (c_0 > 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
                  r_0, xk_0, xd_0, cmp_0, &v_1, 0), _fx_catch_0);
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  &_fx_g18Ast_typecheck__Red, l_0, yk_0, yd_0, v_1, fx_result), _fx_catch_0);
         }
         else {
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  &_fx_g18Ast_typecheck__Red, l_0, xk_0, xd_0, r_0, fx_result), _fx_catch_0);
         }

      _fx_catch_0: ;
         if (v_1) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_1);
         }
         if (v_0) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
         }
         goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_1 = &t_0->u.Node;
      if (vcase_1->t0.tag == 2) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_2 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_3 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t r_1 = vcase_1->t4;
         _fx_LN16Ast__env_entry_t yd_1 = vcase_1->t3;
         _fx_R9Ast__id_t* yk_1 = &vcase_1->t2;
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t l_1 = vcase_1->t1;
         int_ c_1;
         FX_CALL(cmp_0->fp(xk_0, yk_1, &c_1, cmp_0->fcv), _fx_catch_1);
         if (c_1 < 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
                  l_1, xk_0, xd_0, cmp_0, &v_2, 0), _fx_catch_1);
            FX_CALL(
               _fx_M13Ast_typecheckFM12balance_leftNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  v_2, yk_1, yd_1, r_1, fx_result, 0), _fx_catch_1);
         }
         else if (c_1 > 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
                  r_1, xk_0, xd_0, cmp_0, &v_3, 0), _fx_catch_1);
            FX_CALL(
               _fx_M13Ast_typecheckFM13balance_rightNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  l_1, yk_1, yd_1, v_3, fx_result, 0), _fx_catch_1);
         }
         else {
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  &_fx_g20Ast_typecheck__Black, l_1, xk_0, xd_0, r_1, fx_result), _fx_catch_1);
         }

      _fx_catch_1: ;
         if (v_3) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_3);
         }
         if (v_2) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
         }
         goto _fx_endmatch_0;
      }
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
         &_fx_g18Ast_typecheck__Red, _fx_g22Ast_typecheck__Empty1_, xk_0, xd_0, _fx_g22Ast_typecheck__Empty1_, fx_result),
      _fx_catch_2);

_fx_catch_2: ;

_fx_endmatch_0: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7update_LR9Ast__id_t3Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tFPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_tLR9Ast__id_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t_0,
   struct _fx_FPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t* f_0,
   struct _fx_LR9Ast__id_t_data_t* res_0,
   struct _fx_LR9Ast__id_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LR9Ast__id_t result_0 = 0;
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t t_1 = 0;
   _fx_FPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t f_1 = {0};
   _fx_LR9Ast__id_t res_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_COPY_PTR(t_0, &t_1);
   FX_COPY_FP(f_0, &f_1);
   FX_COPY_PTR(res_0, &res_1);
   for (;;) {
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t t_2 = 0;
      _fx_FPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t f_2 = {0};
      _fx_LR9Ast__id_t res_2 = 0;
      FX_COPY_PTR(t_1, &t_2);
      FX_COPY_FP(&f_1, &f_2);
      FX_COPY_PTR(res_1, &res_2);
      if ((t_2 != 0) + 1 == 2) {
         _fx_LR9Ast__id_t v_0 = 0;
         _fx_LR9Ast__id_t v_1 = 0;
         _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
            vcase_0 = &t_2->u.Node;
         FX_CALL(
            _fx_M13Ast_typecheckFM7update_LR9Ast__id_t3Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tFPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_tLR9Ast__id_t(
               vcase_0->t1, &f_2, res_2, &v_0, 0), _fx_catch_0);
         FX_CALL(f_2.fp(&vcase_0->t2, vcase_0->t3, v_0, &v_1, f_2.fcv), _fx_catch_0);
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t* r_0 = &vcase_0->t4;
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_1);
         FX_COPY_PTR(*r_0, &t_1);
         FX_FREE_FP(&f_1);
         FX_COPY_FP(&f_2, &f_1);
         FX_FREE_LIST_SIMPLE(&res_1);
         FX_COPY_PTR(v_1, &res_1);

      _fx_catch_0: ;
         FX_FREE_LIST_SIMPLE(&v_1);
         FX_FREE_LIST_SIMPLE(&v_0);
      }
      else {
         FX_FREE_LIST_SIMPLE(&result_0); FX_COPY_PTR(res_2, &result_0); FX_BREAK(_fx_catch_1);  _fx_catch_1: ;
      }
      FX_CHECK_EXN(_fx_catch_2);

   _fx_catch_2: ;
      FX_FREE_LIST_SIMPLE(&res_2);
      FX_FREE_FP(&f_2);
      if (t_2) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(result_0, fx_result);

_fx_cleanup: ;
   FX_FREE_LIST_SIMPLE(&result_0);
   if (t_1) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_1);
   }
   FX_FREE_FP(&f_1);
   FX_FREE_LIST_SIMPLE(&res_1);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7update_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t_data_t* t_0,
   struct _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t*
      f_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* res_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t result_0 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t t_1 = 0;
   _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t
      f_1 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t res_1 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_COPY_PTR(t_0, &t_1);
   FX_COPY_FP(f_0, &f_1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(res_0, &res_1);
   for (;;) {
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t t_2 = 0;
      _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t
         f_2 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t res_2 = {0};
      FX_COPY_PTR(t_1, &t_2);
      FX_COPY_FP(&f_1, &f_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&res_1, &res_2);
      if ((t_2 != 0) + 1 == 2) {
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_0 = {0};
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_1 = {0};
         _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
            vcase_0 = &t_2->u.Node;
         FX_CALL(
            _fx_M13Ast_typecheckFM7update_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
               vcase_0->t1, &f_2, &res_2, &v_0, 0), _fx_catch_0);
         FX_CALL(f_2.fp(&vcase_0->t2, vcase_0->t3, &v_0, &v_1, f_2.fcv), _fx_catch_0);
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t* r_0 = &vcase_0->t4;
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_1);
         FX_COPY_PTR(*r_0, &t_1);
         FX_FREE_FP(&f_1);
         FX_COPY_FP(&f_2, &f_1);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&res_1);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_1, &res_1);

      _fx_catch_0: ;
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_1);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
      }
      else {
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&result_0);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&res_2, &result_0);
         FX_BREAK(_fx_catch_1);

      _fx_catch_1: ;
      }
      FX_CHECK_EXN(_fx_catch_2);

   _fx_catch_2: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&res_2);
      FX_FREE_FP(&f_2);
      if (t_2) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&result_0, fx_result);

_fx_cleanup: ;
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&result_0);
   if (t_1) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_1);
   }
   FX_FREE_FP(&f_1);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&res_1);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
   struct _fx_N12Set__color_t* arg0,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* arg1,
   struct _fx_R9Ast__id_t* arg2,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* arg3,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t** fx_result)
{
   FX_MAKE_RECURSIVE_VARIANT_IMPL_START(_fx_Nt11Set__tree_t1R9Ast__id_t);
   v->u.Node.t0 = *arg0;
   FX_COPY_PTR(arg1, &v->u.Node.t1);
   v->u.Node.t2 = *arg2;
   FX_COPY_PTR(arg3, &v->u.Node.t3);
   return 0;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12balance_leftNt11Set__tree_t1R9Ast__id_t3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* l_0,
   struct _fx_R9Ast__id_t* x_0,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* r_0,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if ((l_0 != 0) + 1 == 2) {
      _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_0 = &l_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Set__tree_t1R9Ast__id_t v_0 = vcase_0->t1;
         if ((v_0 != 0) + 1 == 2) {
            _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_1 = &v_0->u.Node;
            if (vcase_1->t0.tag == 1) {
               _fx_Nt11Set__tree_t1R9Ast__id_t v_1 = 0;
               _fx_Nt11Set__tree_t1R9Ast__id_t v_2 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, vcase_1->t1, &vcase_1->t2, vcase_1->t3, &v_1), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, vcase_0->t3, x_0, r_0, &v_2), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g20Ast_typecheck__Red1_, v_1, &vcase_0->t2, v_2, fx_result), _fx_catch_0);

            _fx_catch_0: ;
               if (v_2) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_2);
               }
               if (v_1) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_1);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   if ((l_0 != 0) + 1 == 2) {
      _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_2 = &l_0->u.Node;
      if (vcase_2->t0.tag == 1) {
         _fx_Nt11Set__tree_t1R9Ast__id_t v_3 = vcase_2->t3;
         if ((v_3 != 0) + 1 == 2) {
            _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_3 = &v_3->u.Node;
            if (vcase_3->t0.tag == 1) {
               _fx_Nt11Set__tree_t1R9Ast__id_t v_4 = 0;
               _fx_Nt11Set__tree_t1R9Ast__id_t v_5 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, vcase_2->t1, &vcase_2->t2, vcase_3->t1, &v_4), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, vcase_3->t3, x_0, r_0, &v_5), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g20Ast_typecheck__Red1_, v_4, &vcase_3->t2, v_5, fx_result), _fx_catch_1);

            _fx_catch_1: ;
               if (v_5) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_5);
               }
               if (v_4) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_4);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
         &_fx_g22Ast_typecheck__Black1_, l_0, x_0, r_0, fx_result), _fx_catch_2);

_fx_catch_2: ;

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM13balance_rightNt11Set__tree_t1R9Ast__id_t3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* l_0,
   struct _fx_R9Ast__id_t* x_0,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* r_0,
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if ((r_0 != 0) + 1 == 2) {
      _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_0 = &r_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Set__tree_t1R9Ast__id_t v_0 = vcase_0->t1;
         if ((v_0 != 0) + 1 == 2) {
            _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_1 = &v_0->u.Node;
            if (vcase_1->t0.tag == 1) {
               _fx_Nt11Set__tree_t1R9Ast__id_t v_1 = 0;
               _fx_Nt11Set__tree_t1R9Ast__id_t v_2 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, l_0, x_0, vcase_1->t1, &v_1), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, vcase_1->t3, &vcase_0->t2, vcase_0->t3, &v_2), _fx_catch_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g20Ast_typecheck__Red1_, v_1, &vcase_1->t2, v_2, fx_result), _fx_catch_0);

            _fx_catch_0: ;
               if (v_2) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_2);
               }
               if (v_1) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_1);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   if ((r_0 != 0) + 1 == 2) {
      _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_2 = &r_0->u.Node;
      if (vcase_2->t0.tag == 1) {
         _fx_Nt11Set__tree_t1R9Ast__id_t v_3 = vcase_2->t3;
         if ((v_3 != 0) + 1 == 2) {
            _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_3 = &v_3->u.Node;
            if (vcase_3->t0.tag == 1) {
               _fx_Nt11Set__tree_t1R9Ast__id_t v_4 = 0;
               _fx_Nt11Set__tree_t1R9Ast__id_t v_5 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, l_0, x_0, vcase_2->t1, &v_4), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, vcase_3->t1, &vcase_3->t2, vcase_3->t3, &v_5), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g20Ast_typecheck__Red1_, v_4, &vcase_2->t2, v_5, fx_result), _fx_catch_1);

            _fx_catch_1: ;
               if (v_5) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_5);
               }
               if (v_4) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_4);
               }
               goto _fx_endmatch_0;
            }
         }
      }
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
         &_fx_g22Ast_typecheck__Black1_, l_0, x_0, r_0, fx_result), _fx_catch_2);

_fx_catch_2: ;

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12add_to_tree_T2Nt11Set__tree_t1R9Ast__id_ti3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t_0,
   struct _fx_R9Ast__id_t* x_0,
   struct _fx_FPi2R9Ast__id_tR9Ast__id_t* cmp_0,
   struct _fx_T2Nt11Set__tree_t1R9Ast__id_ti* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int tag_0 = (t_0 != 0) + 1;
   if (tag_0 == 2) {
      _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_0 = &t_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_T2Nt11Set__tree_t1R9Ast__id_ti v_0 = {0};
         _fx_Nt11Set__tree_t1R9Ast__id_t l_0 = 0;
         _fx_Nt11Set__tree_t1R9Ast__id_t v_1 = 0;
         _fx_T2Nt11Set__tree_t1R9Ast__id_ti v_2 = {0};
         _fx_Nt11Set__tree_t1R9Ast__id_t r_0 = 0;
         _fx_Nt11Set__tree_t1R9Ast__id_t v_3 = 0;
         _fx_Nt11Set__tree_t1R9Ast__id_t r_1 = vcase_0->t3;
         _fx_R9Ast__id_t* y_0 = &vcase_0->t2;
         _fx_Nt11Set__tree_t1R9Ast__id_t l_1 = vcase_0->t1;
         int_ c_0;
         FX_CALL(cmp_0->fp(x_0, y_0, &c_0, cmp_0->fcv), _fx_catch_0);
         if (c_0 < 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_T2Nt11Set__tree_t1R9Ast__id_ti3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  l_1, x_0, cmp_0, &v_0, 0), _fx_catch_0);
            FX_COPY_PTR(v_0.t0, &l_0);
            int_ dsz_0 = v_0.t1;
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                  &_fx_g20Ast_typecheck__Red1_, l_0, y_0, r_1, &v_1), _fx_catch_0);
            _fx_make_T2Nt11Set__tree_t1R9Ast__id_ti(v_1, dsz_0, fx_result);
         }
         else if (c_0 > 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_T2Nt11Set__tree_t1R9Ast__id_ti3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  r_1, x_0, cmp_0, &v_2, 0), _fx_catch_0);
            FX_COPY_PTR(v_2.t0, &r_0);
            int_ dsz_1 = v_2.t1;
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                  &_fx_g20Ast_typecheck__Red1_, l_1, y_0, r_0, &v_3), _fx_catch_0);
            _fx_make_T2Nt11Set__tree_t1R9Ast__id_ti(v_3, dsz_1, fx_result);
         }
         else {
            _fx_make_T2Nt11Set__tree_t1R9Ast__id_ti(t_0, 0, fx_result);
         }

      _fx_catch_0: ;
         if (v_3) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_3);
         }
         if (r_0) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&r_0);
         }
         _fx_free_T2Nt11Set__tree_t1R9Ast__id_ti(&v_2);
         if (v_1) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_1);
         }
         if (l_0) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&l_0);
         }
         _fx_free_T2Nt11Set__tree_t1R9Ast__id_ti(&v_0);
         goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 2) {
      _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_1 = &t_0->u.Node;
      if (vcase_1->t0.tag == 2) {
         _fx_T2Nt11Set__tree_t1R9Ast__id_ti v_4 = {0};
         _fx_Nt11Set__tree_t1R9Ast__id_t l_2 = 0;
         _fx_Nt11Set__tree_t1R9Ast__id_t v_5 = 0;
         _fx_T2Nt11Set__tree_t1R9Ast__id_ti v_6 = {0};
         _fx_Nt11Set__tree_t1R9Ast__id_t r_2 = 0;
         _fx_Nt11Set__tree_t1R9Ast__id_t v_7 = 0;
         _fx_Nt11Set__tree_t1R9Ast__id_t r_3 = vcase_1->t3;
         _fx_R9Ast__id_t* y_1 = &vcase_1->t2;
         _fx_Nt11Set__tree_t1R9Ast__id_t l_3 = vcase_1->t1;
         int_ c_1;
         FX_CALL(cmp_0->fp(x_0, y_1, &c_1, cmp_0->fcv), _fx_catch_1);
         if (c_1 < 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_T2Nt11Set__tree_t1R9Ast__id_ti3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  l_3, x_0, cmp_0, &v_4, 0), _fx_catch_1);
            FX_COPY_PTR(v_4.t0, &l_2);
            int_ dsz_2 = v_4.t1;
            if (dsz_2 > 0) {
               FX_CALL(
                  _fx_M13Ast_typecheckFM12balance_leftNt11Set__tree_t1R9Ast__id_t3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     l_2, y_1, r_3, &v_5, 0), _fx_catch_1);
            }
            else {
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, l_2, y_1, r_3, &v_5), _fx_catch_1);
            }
            _fx_make_T2Nt11Set__tree_t1R9Ast__id_ti(v_5, dsz_2, fx_result);
         }
         else if (c_1 > 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_T2Nt11Set__tree_t1R9Ast__id_ti3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  r_3, x_0, cmp_0, &v_6, 0), _fx_catch_1);
            FX_COPY_PTR(v_6.t0, &r_2);
            int_ dsz_3 = v_6.t1;
            if (dsz_3 > 0) {
               FX_CALL(
                  _fx_M13Ast_typecheckFM13balance_rightNt11Set__tree_t1R9Ast__id_t3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     l_3, y_1, r_2, &v_7, 0), _fx_catch_1);
            }
            else {
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, l_3, y_1, r_2, &v_7), _fx_catch_1);
            }
            _fx_make_T2Nt11Set__tree_t1R9Ast__id_ti(v_7, dsz_3, fx_result);
         }
         else {
            _fx_make_T2Nt11Set__tree_t1R9Ast__id_ti(t_0, 0, fx_result);
         }

      _fx_catch_1: ;
         if (v_7) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_7);
         }
         if (r_2) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&r_2);
         }
         _fx_free_T2Nt11Set__tree_t1R9Ast__id_ti(&v_6);
         if (v_5) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_5);
         }
         if (l_2) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&l_2);
         }
         _fx_free_T2Nt11Set__tree_t1R9Ast__id_ti(&v_4);
         goto _fx_endmatch_0;
      }
   }
   _fx_Nt11Set__tree_t1R9Ast__id_t v_8 = 0;
   FX_CALL(
      _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
         &_fx_g20Ast_typecheck__Red1_, _fx_g22Ast_typecheck__Empty2_, x_0, _fx_g22Ast_typecheck__Empty2_, &v_8), _fx_catch_2);
   _fx_make_T2Nt11Set__tree_t1R9Ast__id_ti(v_8, 1, fx_result);

_fx_catch_2: ;
   if (v_8) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_8);
   }

_fx_endmatch_0: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM3addRt6Set__t1R9Ast__id_t2Rt6Set__t1R9Ast__id_tR9Ast__id_t(
   struct _fx_Rt6Set__t1R9Ast__id_t* s_0,
   struct _fx_R9Ast__id_t* x_0,
   struct _fx_Rt6Set__t1R9Ast__id_t* fx_result,
   void* fx_fv)
{
   _fx_Nt11Set__tree_t1R9Ast__id_t v_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_1 = {0};
   _fx_T2Nt11Set__tree_t1R9Ast__id_ti v_2 = {0};
   _fx_Nt11Set__tree_t1R9Ast__id_t t_0 = 0;
   _fx_T2Nt11Set__tree_t1R9Ast__id_tB v_3 = {0};
   _fx_Nt11Set__tree_t1R9Ast__id_t t_1 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_4 = {0};
   int fx_status = 0;
   FX_COPY_PTR(s_0->root, &v_0);
   FX_COPY_FP(&s_0->cmp, &v_1);
   FX_CALL(
      _fx_M13Ast_typecheckFM12add_to_tree_T2Nt11Set__tree_t1R9Ast__id_ti3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
         v_0, x_0, &v_1, &v_2, 0), _fx_cleanup);
   FX_COPY_PTR(v_2.t0, &t_0);
   int_ dsz_0 = v_2.t1;
   if ((t_0 != 0) + 1 == 2) {
      _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_0 = &t_0->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Set__tree_t1R9Ast__id_t v_5 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
               &_fx_g22Ast_typecheck__Black1_, vcase_0->t1, &vcase_0->t2, vcase_0->t3, &v_5), _fx_catch_0);
         _fx_make_T2Nt11Set__tree_t1R9Ast__id_tB(v_5, false, &v_3);

      _fx_catch_0: ;
         if (v_5) {
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_5);
         }
         goto _fx_endmatch_0;
      }
   }
   _fx_make_T2Nt11Set__tree_t1R9Ast__id_tB(t_0, true, &v_3);

_fx_endmatch_0: ;
   FX_CHECK_EXN(_fx_cleanup);
   FX_COPY_PTR(v_3.t0, &t_1);
   FX_COPY_FP(&s_0->cmp, &v_4);
   _fx_make_Rt6Set__t1R9Ast__id_t(t_1, s_0->size + dsz_0, &v_4, fx_result);

_fx_cleanup: ;
   if (v_0) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_0);
   }
   FX_FREE_FP(&v_1);
   _fx_free_T2Nt11Set__tree_t1R9Ast__id_ti(&v_2);
   if (t_0) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_0);
   }
   _fx_free_T2Nt11Set__tree_t1R9Ast__id_tB(&v_3);
   if (t_1) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_1);
   }
   FX_FREE_FP(&v_4);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM12update_list_LR9Ast__id_t2Nt11Set__tree_t1R9Ast__id_tLR9Ast__id_t(
   struct _fx_Nt11Set__tree_t1R9Ast__id_t_data_t* t_0,
   struct _fx_LR9Ast__id_t_data_t* res_0,
   struct _fx_LR9Ast__id_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LR9Ast__id_t result_0 = 0;
   _fx_Nt11Set__tree_t1R9Ast__id_t t_1 = 0;
   _fx_LR9Ast__id_t res_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_COPY_PTR(t_0, &t_1);
   FX_COPY_PTR(res_0, &res_1);
   for (;;) {
      _fx_Nt11Set__tree_t1R9Ast__id_t t_2 = 0;
      _fx_LR9Ast__id_t res_2 = 0;
      FX_COPY_PTR(t_1, &t_2);
      FX_COPY_PTR(res_1, &res_2);
      if ((t_2 != 0) + 1 == 2) {
         _fx_LR9Ast__id_t v_0 = 0;
         _fx_LR9Ast__id_t v_1 = 0;
         _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_0 = &t_2->u.Node;
         FX_CALL(
            _fx_M13Ast_typecheckFM12update_list_LR9Ast__id_t2Nt11Set__tree_t1R9Ast__id_tLR9Ast__id_t(vcase_0->t3, res_2, &v_0,
               0), _fx_catch_0);
         FX_CALL(_fx_cons_LR9Ast__id_t(&vcase_0->t2, v_0, true, &v_1), _fx_catch_0);
         _fx_Nt11Set__tree_t1R9Ast__id_t* l_0 = &vcase_0->t1;
         _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_1);
         FX_COPY_PTR(*l_0, &t_1);
         FX_FREE_LIST_SIMPLE(&res_1);
         FX_COPY_PTR(v_1, &res_1);

      _fx_catch_0: ;
         FX_FREE_LIST_SIMPLE(&v_1);
         FX_FREE_LIST_SIMPLE(&v_0);
      }
      else {
         FX_FREE_LIST_SIMPLE(&result_0); FX_COPY_PTR(res_2, &result_0); FX_BREAK(_fx_catch_1);  _fx_catch_1: ;
      }
      FX_CHECK_EXN(_fx_catch_2);

   _fx_catch_2: ;
      FX_FREE_LIST_SIMPLE(&res_2);
      if (t_2) {
         _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(result_0, fx_result);

_fx_cleanup: ;
   FX_FREE_LIST_SIMPLE(&result_0);
   if (t_1) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_1);
   }
   FX_FREE_LIST_SIMPLE(&res_1);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   struct _fx_R10Ast__loc_t* loc_0,
   bool update_refs_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t undo_stack_ref_0 = 0;
   _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB
      rec_undo_stack_ref_0 = 0;
   _fx_FPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t maybe_unify__0 = {0};
   _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB
      rec_undo_stack_0 = 0;
   _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t undo_stack_0 = 0;
   int fx_status = 0;
   FX_CALL(_fx_make_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(0, &undo_stack_ref_0), _fx_cleanup);
   FX_CALL(
      _fx_make_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
         0, &rec_undo_stack_ref_0), _fx_cleanup);
   _fx_M13Ast_typecheckFM7make_fpFPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t2rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
      rec_undo_stack_ref_0, undo_stack_ref_0, &maybe_unify__0);
   bool ok_0;
   FX_CALL(maybe_unify__0.fp(t1_0, t2_0, loc_0, &ok_0, maybe_unify__0.fcv), _fx_cleanup);
   bool t_0;
   if (!ok_0) {
      t_0 = true;
   }
   else {
      t_0 = !update_refs_0;
   }
   if (t_0) {
      FX_COPY_PTR(rec_undo_stack_ref_0->data, &rec_undo_stack_0);
      _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB
         lst_0 = rec_undo_stack_0;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB r_0 = 0;
         _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB prev_0 = {0};
         _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB*
            __pat___0 = &lst_0->hd;
         FX_COPY_PTR(__pat___0->t0, &r_0);
         _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&__pat___0->t1, &prev_0);
         _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* v_0 = &r_0->data;
         _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(v_0);
         _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&prev_0, v_0);
         _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&prev_0);
         if (r_0) {
            _fx_free_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&r_0);
         }
      }
      FX_COPY_PTR(undo_stack_ref_0->data, &undo_stack_0);
      _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t lst_1 = undo_stack_0;
      for (; lst_1; lst_1 = lst_1->tl) {
         _fx_rNt6option1N10Ast__typ_t r_1 = 0;
         _fx_Nt6option1N10Ast__typ_t old_val_0 = 0;
         _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t* __pat___1 = &lst_1->hd;
         FX_COPY_PTR(__pat___1->t0, &r_1);
         FX_COPY_PTR(__pat___1->t1, &old_val_0);
         _fx_Nt6option1N10Ast__typ_t* v_1 = &r_1->data;
         _fx_free_Nt6option1N10Ast__typ_t(v_1);
         FX_COPY_PTR(old_val_0, v_1);
         if (old_val_0) {
            _fx_free_Nt6option1N10Ast__typ_t(&old_val_0);
         }
         if (r_1) {
            _fx_free_rNt6option1N10Ast__typ_t(&r_1);
         }
      }
   }
   *fx_result = ok_0;

_fx_cleanup: ;
   if (undo_stack_ref_0) {
      _fx_free_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&undo_stack_ref_0);
   }
   if (rec_undo_stack_ref_0) {
      _fx_free_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
         &rec_undo_stack_ref_0);
   }
   FX_FREE_FP(&maybe_unify__0);
   if (rec_undo_stack_0) {
      _fx_free_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
         &rec_undo_stack_0);
   }
   if (undo_stack_0) {
      _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&undo_stack_0);
   }
   return fx_status;
}

static int _fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* r1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_rNt6option1N10Ast__typ_t r1_1 = 0;
   _fx_N10Ast__typ_t t2_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   bool result_0 = 0;
   FX_COPY_PTR(r1_0, &r1_1);
   FX_COPY_PTR(t2_0, &t2_1);
   for (;;) {
      _fx_rNt6option1N10Ast__typ_t r1_2 = 0;
      _fx_N10Ast__typ_t t2_2 = 0;
      FX_COPY_PTR(r1_1, &r1_2);
      FX_COPY_PTR(t2_1, &t2_2);
      int tag_0 = FX_REC_VARIANT_TAG(t2_2);
      if (tag_0 == 14) {
         _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_0 = &t2_2->u.TypFun;
         bool res_0;
         FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLN10Ast__typ_t(r1_2, vcase_0->t0, &res_0, 0),
            _fx_catch_0);
         if (res_0) {
            result_0 = true; FX_BREAK(_fx_catch_0);
         }
         else {
            _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
            FX_COPY_PTR(r1_2, &r1_1);
            _fx_N10Ast__typ_t* rt2_0 = &vcase_0->t1;
            _fx_free_N10Ast__typ_t(&t2_1);
            FX_COPY_PTR(*rt2_0, &t2_1);
         }

      _fx_catch_0: ;
         goto _fx_endmatch_0;
      }
      if (tag_0 == 15) {
         _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
         FX_COPY_PTR(r1_2, &r1_1);
         _fx_N10Ast__typ_t* t2__0 = &t2_2->u.TypList;
         _fx_free_N10Ast__typ_t(&t2_1);
         FX_COPY_PTR(*t2__0, &t2_1);
         goto _fx_endmatch_0;
      }
      if (tag_0 == 16) {
         _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
         FX_COPY_PTR(r1_2, &r1_1);
         _fx_N10Ast__typ_t* t2__1 = &t2_2->u.TypVector;
         _fx_free_N10Ast__typ_t(&t2_1);
         FX_COPY_PTR(*t2__1, &t2_1);
         goto _fx_endmatch_0;
      }
      if (tag_0 == 17) {
         bool result_1;
         FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLN10Ast__typ_t(r1_2, t2_2->u.TypTuple, &result_1, 0),
            _fx_catch_1);
         result_0 = result_1;
         FX_BREAK(_fx_catch_1);

      _fx_catch_1: ;
         goto _fx_endmatch_0;
      }
      if (tag_0 == 2) {
         _fx_Nt6option1N10Ast__typ_t v_0 = t2_2->u.TypVarTuple;
         if ((v_0 != 0) + 1 == 2) {
            _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
            FX_COPY_PTR(r1_2, &r1_1);
            _fx_N10Ast__typ_t* t2__2 = &v_0->u.Some;
            _fx_free_N10Ast__typ_t(&t2_1);
            FX_COPY_PTR(*t2__2, &t2_1);
            goto _fx_endmatch_0;
         }
      }
      if (tag_0 == 2) {
         result_0 = false; FX_BREAK(_fx_catch_2);  _fx_catch_2: ; goto _fx_endmatch_0;
      }
      if (tag_0 == 18) {
         _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
         FX_COPY_PTR(r1_2, &r1_1);
         _fx_N10Ast__typ_t* t2__3 = &t2_2->u.TypRef;
         _fx_free_N10Ast__typ_t(&t2_1);
         FX_COPY_PTR(*t2__3, &t2_1);
         goto _fx_endmatch_0;
      }
      if (tag_0 == 19) {
         _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
         FX_COPY_PTR(r1_2, &r1_1);
         _fx_N10Ast__typ_t* et2_0 = &t2_2->u.TypArray.t1;
         _fx_free_N10Ast__typ_t(&t2_1);
         FX_COPY_PTR(*et2_0, &t2_1);
         goto _fx_endmatch_0;
      }
      if (tag_0 == 3) {
         _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
         FX_COPY_PTR(r1_2, &r1_1);
         _fx_N10Ast__typ_t* et2_1 = &t2_2->u.TypVarArray;
         _fx_free_N10Ast__typ_t(&t2_1);
         FX_COPY_PTR(*et2_1, &t2_1);
         goto _fx_endmatch_0;
      }
      if (tag_0 == 20) {
         _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_1 = {0};
         _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&t2_2->u.TypRecord->data, &v_1);
         bool result_2;
         FX_CALL(
            _fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
               r1_2, v_1.t0, &result_2, 0), _fx_catch_3);
         result_0 = result_2;
         FX_BREAK(_fx_catch_3);

      _fx_catch_3: ;
         _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_1);
         goto _fx_endmatch_0;
      }
      if (tag_0 == 1) {
         _fx_Nt6option1N10Ast__typ_t v_2 = 0;
         _fx_rNt6option1N10Ast__typ_t r2_0 = t2_2->u.TypVar;
         bool v_3 = _fx_M13Ast_typecheckFM6__eq__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(r1_2, r2_0, 0);
         if (v_3) {
            result_0 = true; FX_BREAK(_fx_catch_5);
         }
         else {
            FX_COPY_PTR(r2_0->data, &v_2);
            if ((v_2 != 0) + 1 == 2) {
               _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
               FX_COPY_PTR(r1_2, &r1_1);
               _fx_N10Ast__typ_t* t2__4 = &v_2->u.Some;
               _fx_free_N10Ast__typ_t(&t2_1);
               FX_COPY_PTR(*t2__4, &t2_1);
            }
            else {
               result_0 = false; FX_BREAK(_fx_catch_4);  _fx_catch_4: ;
            }
            FX_CHECK_EXN(_fx_catch_5);
         }

      _fx_catch_5: ;
         if (v_2) {
            _fx_free_Nt6option1N10Ast__typ_t(&v_2);
         }
         goto _fx_endmatch_0;
      }
      if (tag_0 == 24) {
         bool result_3;
         FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLN10Ast__typ_t(r1_2, t2_2->u.TypApp.t0, &result_3, 0),
            _fx_catch_6);
         result_0 = result_3;
         FX_BREAK(_fx_catch_6);

      _fx_catch_6: ;
         goto _fx_endmatch_0;
      }
      bool res_1;
      if (tag_0 == 5) {
         res_1 = true;
      }
      else if (tag_0 == 8) {
         res_1 = true;
      }
      else if (tag_0 == 6) {
         res_1 = true;
      }
      else if (tag_0 == 7) {
         res_1 = true;
      }
      else if (tag_0 == 9) {
         res_1 = true;
      }
      else if (tag_0 == 10) {
         res_1 = true;
      }
      else if (tag_0 == 11) {
         res_1 = true;
      }
      else if (tag_0 == 12) {
         res_1 = true;
      }
      else if (tag_0 == 13) {
         res_1 = true;
      }
      else if (tag_0 == 21) {
         res_1 = true;
      }
      else if (tag_0 == 22) {
         res_1 = true;
      }
      else if (tag_0 == 23) {
         res_1 = true;
      }
      else if (tag_0 == 25) {
         res_1 = true;
      }
      else if (tag_0 == 26) {
         res_1 = true;
      }
      else if (tag_0 == 4) {
         res_1 = true;
      }
      else {
         res_1 = false;
      }
      FX_CHECK_EXN(_fx_catch_8);
      if (res_1) {
         result_0 = false; FX_BREAK(_fx_catch_7);  _fx_catch_7: ; goto _fx_endmatch_0;
      }
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_8);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_8);

   _fx_catch_8: ;
      if (t2_2) {
         _fx_free_N10Ast__typ_t(&t2_2);
      }
      if (r1_2) {
         _fx_free_rNt6option1N10Ast__typ_t(&r1_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = result_0;

_fx_cleanup: ;
   if (r1_1) {
      _fx_free_rNt6option1N10Ast__typ_t(&r1_1);
   }
   if (t2_1) {
      _fx_free_N10Ast__typ_t(&t2_1);
   }
   return fx_status;
}

static int _fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLN10Ast__typ_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* r1_0,
   struct _fx_LN10Ast__typ_t_data_t* tl_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   bool __fold_result___0 = false;
   _fx_LN10Ast__typ_t lst_0 = tl_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__typ_t t_0 = lst_0->hd;
      bool v_0;
      FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r1_0, t_0, &v_0, 0), _fx_catch_0);
      if (v_0) {
         __fold_result___0 = true; FX_BREAK(_fx_catch_0);
      }

   _fx_catch_0: ;
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = __fold_result___0;

_fx_cleanup: ;
   return fx_status;
}

static int _fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_rNt6option1N10Ast__typ_t_data_t* r1_0,
   struct _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_data_t* relems_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   bool __fold_result___0 = false;
   _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_0 = relems_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__typ_t t_0 = 0;
      _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___0 = &lst_0->hd;
      FX_COPY_PTR(__pat___0->t2, &t_0);
      bool v_0;
      FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r1_0, t_0, &v_0, 0), _fx_catch_0);
      if (v_0) {
         __fold_result___0 = true; FX_BREAK(_fx_catch_0);
      }

   _fx_catch_0: ;
      if (t_0) {
         _fx_free_N10Ast__typ_t(&t_0);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = __fold_result___0;

_fx_cleanup: ;
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_LN10Ast__typ_t_data_t* tl1_0,
   struct _fx_LN10Ast__typ_t_data_t* tl2_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      rec_undo_stack_ref_0,
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* undo_stack_ref_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_FPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t maybe_unify__0 = {0};
   int fx_status = 0;
   _fx_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_cldata_t*
      cv_0 =
      (_fx_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_cldata_t*)
         fx_fv;
   _fx_M13Ast_typecheckFM7make_fpFPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t2rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
      cv_0->t0, cv_0->t1, &maybe_unify__0);
   int_ v_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(tl1_0, 0);
   int_ v_1 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(tl2_0, 0);
   if (v_0 == v_1) {
      bool __fold_result___0 = true;
      _fx_LN10Ast__typ_t lst_0 = tl1_0;
      _fx_LN10Ast__typ_t lst_1 = tl2_0;
      for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl) {
         _fx_N10Ast__typ_t t2_0 = lst_1->hd;
         _fx_N10Ast__typ_t t1_0 = lst_0->hd;
         bool v_2;
         FX_CALL(maybe_unify__0.fp(t1_0, t2_0, loc_0, &v_2, maybe_unify__0.fcv), _fx_catch_0);
         if (!v_2) {
            __fold_result___0 = false; FX_BREAK(_fx_catch_0);
         }

      _fx_catch_0: ;
         FX_CHECK_BREAK();
         FX_CHECK_EXN(_fx_cleanup);
      }
      int s_0 = !lst_0 + !lst_1;
      FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_cleanup);
      *fx_result = __fold_result___0;
   }
   else {
      *fx_result = false;
   }

_fx_cleanup: ;
   FX_FREE_FP(&maybe_unify__0);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPB5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t2rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      arg0,
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* arg1,
   struct _fx_FPB5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t*
      fx_result)
{
   FX_MAKE_FP_IMPL_START(
      _fx_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_cldata_t,
      _fx_free_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t,
      _fx_M13Ast_typecheckFM12maybe_unify_B5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t);
   FX_COPY_PTR(arg0, &fcv->t0);
   FX_COPY_PTR(arg1, &fcv->t1);
   return 0;
}

static int _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   struct _fx_R10Ast__loc_t* loc_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_FPB5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t
      maybe_unify__0 = {0};
   _fx_N10Ast__typ_t t1_1 = 0;
   _fx_N10Ast__typ_t t2_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t_cldata_t*)fx_fv;
   _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB
      rec_undo_stack_ref_0 = cv_0->t0;
   _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t undo_stack_ref_0 = cv_0->t1;
   _fx_M13Ast_typecheckFM7make_fpFPB5LN10Ast__typ_tLN10Ast__typ_tR10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t2rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
      rec_undo_stack_ref_0, undo_stack_ref_0, &maybe_unify__0);
   _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB*
      rec_undo_stack_0 = &rec_undo_stack_ref_0->data;
   _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t* undo_stack_0 = &undo_stack_ref_0->data;
   bool result_0 = 0;
   FX_COPY_PTR(t1_0, &t1_1);
   FX_COPY_PTR(t2_0, &t2_1);
   _fx_R10Ast__loc_t loc_1 = *loc_0;
   for (;;) {
      _fx_N10Ast__typ_t t1_2 = 0;
      _fx_N10Ast__typ_t t2_2 = 0;
      _fx_Nt6option1N10Ast__typ_t v_0 = 0;
      _fx_Nt6option1N10Ast__typ_t v_1 = 0;
      _fx_Nt6option1N10Ast__typ_t v_2 = 0;
      _fx_Nt6option1N10Ast__typ_t v_3 = 0;
      _fx_Nt6option1N10Ast__typ_t v_4 = 0;
      _fx_Nt6option1N10Ast__typ_t v_5 = 0;
      _fx_Nt6option1N10Ast__typ_t v_6 = 0;
      _fx_Nt6option1N10Ast__typ_t v_7 = 0;
      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_8 = {0};
      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_9 = {0};
      _fx_Nt6option1N10Ast__typ_t v_10 = 0;
      _fx_Nt6option1N10Ast__typ_t v_11 = 0;
      _fx_Nt6option1N10Ast__typ_t v_12 = 0;
      _fx_Nt6option1N10Ast__typ_t v_13 = 0;
      _fx_Nt6option1N10Ast__typ_t v_14 = 0;
      _fx_Nt6option1N10Ast__typ_t v_15 = 0;
      _fx_Nt6option1N10Ast__typ_t v_16 = 0;
      _fx_Nt6option1N10Ast__typ_t v_17 = 0;
      _fx_Nt6option1N10Ast__typ_t v_18 = 0;
      _fx_Nt6option1N10Ast__typ_t v_19 = 0;
      FX_COPY_PTR(t1_1, &t1_2);
      FX_COPY_PTR(t2_1, &t2_2);
      _fx_R10Ast__loc_t loc_2 = loc_1;
      bool res_0;
      if (FX_REC_VARIANT_TAG(t1_2) == 5) {
         if (FX_REC_VARIANT_TAG(t2_2) == 5) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 8) {
         if (FX_REC_VARIANT_TAG(t2_2) == 8) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 10) {
         if (FX_REC_VARIANT_TAG(t2_2) == 10) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 11) {
         if (FX_REC_VARIANT_TAG(t2_2) == 11) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 12) {
         if (FX_REC_VARIANT_TAG(t2_2) == 12) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 13) {
         if (FX_REC_VARIANT_TAG(t2_2) == 13) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 21) {
         if (FX_REC_VARIANT_TAG(t2_2) == 21) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 23) {
         if (FX_REC_VARIANT_TAG(t2_2) == 23) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 25) {
         if (FX_REC_VARIANT_TAG(t2_2) == 25) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 26) {
         if (FX_REC_VARIANT_TAG(t2_2) == 26) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      res_0 = false;

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_42);
      if (res_0) {
         result_0 = true; FX_BREAK(_fx_catch_0);  _fx_catch_0: ; goto _fx_endmatch_7;
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 6) {
         if (FX_REC_VARIANT_TAG(t1_2) == 6) {
            result_0 = t1_2->u.TypSInt == t2_2->u.TypSInt; FX_BREAK(_fx_catch_1);  _fx_catch_1: ; goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 7) {
         if (FX_REC_VARIANT_TAG(t1_2) == 7) {
            result_0 = t1_2->u.TypUInt == t2_2->u.TypUInt; FX_BREAK(_fx_catch_2);  _fx_catch_2: ; goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 9) {
         if (FX_REC_VARIANT_TAG(t1_2) == 9) {
            result_0 = t1_2->u.TypFloat == t2_2->u.TypFloat; FX_BREAK(_fx_catch_3);  _fx_catch_3: ; goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 14) {
         _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_0 = &t2_2->u.TypFun;
         if (FX_REC_VARIANT_TAG(t1_2) == 14) {
            _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_1 = &t1_2->u.TypFun;
            bool res_1;
            FX_CALL(
               maybe_unify__0.fp(vcase_1->t0, vcase_0->t0, &loc_2, rec_undo_stack_ref_0, undo_stack_ref_0, &res_1,
                  maybe_unify__0.fcv), _fx_catch_4);
            if (res_1) {
               _fx_N10Ast__typ_t* rt1_0 = &vcase_1->t1;
               _fx_free_N10Ast__typ_t(&t1_1);
               FX_COPY_PTR(*rt1_0, &t1_1);
               _fx_N10Ast__typ_t* rt2_0 = &vcase_0->t1;
               _fx_free_N10Ast__typ_t(&t2_1);
               FX_COPY_PTR(*rt2_0, &t2_1);
               loc_1 = loc_2;
            }
            else {
               result_0 = false; FX_BREAK(_fx_catch_4);
            }

         _fx_catch_4: ;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 15) {
         if (FX_REC_VARIANT_TAG(t1_2) == 15) {
            _fx_N10Ast__typ_t* et1_0 = &t1_2->u.TypList;
            _fx_free_N10Ast__typ_t(&t1_1);
            FX_COPY_PTR(*et1_0, &t1_1);
            _fx_N10Ast__typ_t* et2_0 = &t2_2->u.TypList;
            _fx_free_N10Ast__typ_t(&t2_1);
            FX_COPY_PTR(*et2_0, &t2_1);
            loc_1 = loc_2;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 16) {
         if (FX_REC_VARIANT_TAG(t1_2) == 16) {
            _fx_N10Ast__typ_t* et1_1 = &t1_2->u.TypVector;
            _fx_free_N10Ast__typ_t(&t1_1);
            FX_COPY_PTR(*et1_1, &t1_1);
            _fx_N10Ast__typ_t* et2_1 = &t2_2->u.TypVector;
            _fx_free_N10Ast__typ_t(&t2_1);
            FX_COPY_PTR(*et2_1, &t2_1);
            loc_1 = loc_2;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 17) {
         if (FX_REC_VARIANT_TAG(t1_2) == 17) {
            bool result_1;
            FX_CALL(
               maybe_unify__0.fp(t1_2->u.TypTuple, t2_2->u.TypTuple, &loc_2, rec_undo_stack_ref_0, undo_stack_ref_0, &result_1,
                  maybe_unify__0.fcv), _fx_catch_5);
            result_0 = result_1;
            FX_BREAK(_fx_catch_5);

         _fx_catch_5: ;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 1) {
         if (FX_REC_VARIANT_TAG(t1_2) == 1) {
            _fx_rNt6option1N10Ast__typ_t r1_0 = t1_2->u.TypVar;
            FX_COPY_PTR(r1_0->data, &v_0);
            if ((v_0 != 0) + 1 == 2) {
               _fx_N10Ast__typ_t v_20 = v_0->u.Some;
               if (FX_REC_VARIANT_TAG(v_20) == 2) {
                  _fx_Nt6option1N10Ast__typ_t t1_opt_0 = v_20->u.TypVarTuple;
                  _fx_rNt6option1N10Ast__typ_t r2_0 = t2_2->u.TypVar;
                  FX_COPY_PTR(r2_0->data, &v_1);
                  if ((v_1 != 0) + 1 == 2) {
                     _fx_N10Ast__typ_t v_21 = v_1->u.Some;
                     if (FX_REC_VARIANT_TAG(v_21) == 2) {
                        _fx_Nt6option1N10Ast__typ_t v_22 = 0;
                        _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_23 = {0};
                        _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_24 = 0;
                        _fx_Nt6option1N10Ast__typ_t v_25 = 0;
                        _fx_Nt6option1N10Ast__typ_t t2_opt_0 = v_21->u.TypVarTuple;
                        bool v_26 =
                           _fx_M13Ast_typecheckFM6__eq__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(r1_0, r2_0, 0);
                        if (v_26) {
                           result_0 = true; FX_BREAK(_fx_catch_7);
                        }
                        else {
                           bool v_27;
                           bool res_2;
                           FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r2_0, t1_2, &res_2, 0),
                              _fx_catch_7);
                           if (res_2) {
                              v_27 = true;
                           }
                           else {
                              FX_CALL(
                                 _fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r1_0, t2_2, &v_27, 0),
                                 _fx_catch_7);
                           }
                           if (v_27) {
                              result_0 = false; FX_BREAK(_fx_catch_7);
                           }
                           else {
                              bool ok_0;
                              if ((t2_opt_0 != 0) + 1 == 2) {
                                 if ((t1_opt_0 != 0) + 1 == 2) {
                                    FX_CALL(
                                       _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(
                                          t1_opt_0->u.Some, t2_opt_0->u.Some, &loc_2, &ok_0, fx_fv), _fx_catch_6);

                                 _fx_catch_6: ;
                                    goto _fx_endmatch_1;
                                 }
                              }
                              ok_0 = true;

                           _fx_endmatch_1: ;
                              FX_CHECK_EXN(_fx_catch_7);
                              if (ok_0) {
                                 FX_COPY_PTR(r2_0->data, &v_22);
                                 _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r2_0, v_22, &v_23);
                                 FX_CALL(
                                    _fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_23, *undo_stack_0, true,
                                       &v_24), _fx_catch_7);
                                 _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                                 FX_COPY_PTR(v_24, undo_stack_0);
                                 FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t1_2, &v_25),
                                    _fx_catch_7);
                                 _fx_Nt6option1N10Ast__typ_t* v_28 = &r2_0->data;
                                 _fx_free_Nt6option1N10Ast__typ_t(v_28);
                                 FX_COPY_PTR(v_25, v_28);
                              }
                              result_0 = ok_0;
                              FX_BREAK(_fx_catch_7);
                           }
                        }

                     _fx_catch_7: ;
                        if (v_25) {
                           _fx_free_Nt6option1N10Ast__typ_t(&v_25);
                        }
                        if (v_24) {
                           _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_24);
                        }
                        _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_23);
                        if (v_22) {
                           _fx_free_Nt6option1N10Ast__typ_t(&v_22);
                        }
                        goto _fx_endmatch_7;
                     }
                  }
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 1) {
         FX_COPY_PTR(t1_2->u.TypVar->data, &v_2);
         if ((v_2 != 0) + 1 == 2) {
            if (FX_REC_VARIANT_TAG(v_2->u.Some) == 2) {
               if (FX_REC_VARIANT_TAG(t2_2) == 1) {
                  FX_COPY_PTR(t2_2->u.TypVar->data, &v_3);
                  if ((v_3 != 0) + 1 == 2) {
                     _fx_N10Ast__typ_t* t2__0 = &v_3->u.Some;
                     _fx_free_N10Ast__typ_t(&t1_1);
                     FX_COPY_PTR(*t2__0, &t1_1);
                     _fx_free_N10Ast__typ_t(&t2_1);
                     FX_COPY_PTR(t1_2, &t2_1);
                     loc_1 = loc_2;
                     goto _fx_endmatch_7;
                  }
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 1) {
         if (FX_REC_VARIANT_TAG(t2_2) == 17) {
            FX_COPY_PTR(t1_2->u.TypVar->data, &v_4);
            if ((v_4 != 0) + 1 == 2) {
               if (FX_REC_VARIANT_TAG(v_4->u.Some) == 2) {
                  _fx_free_N10Ast__typ_t(&t1_1);
                  FX_COPY_PTR(t2_2, &t1_1);
                  _fx_free_N10Ast__typ_t(&t2_1);
                  FX_COPY_PTR(t1_2, &t2_1);
                  loc_1 = loc_2;
                  goto _fx_endmatch_7;
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 1) {
         if (FX_REC_VARIANT_TAG(t1_2) == 17) {
            _fx_LN10Ast__typ_t tl1_0 = t1_2->u.TypTuple;
            _fx_rNt6option1N10Ast__typ_t r2_1 = t2_2->u.TypVar;
            FX_COPY_PTR(r2_1->data, &v_5);
            if ((v_5 != 0) + 1 == 2) {
               _fx_N10Ast__typ_t v_29 = v_5->u.Some;
               if (FX_REC_VARIANT_TAG(v_29) == 2) {
                  _fx_Nt6option1N10Ast__typ_t v_30 = 0;
                  _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_31 = {0};
                  _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_32 = 0;
                  _fx_Nt6option1N10Ast__typ_t v_33 = 0;
                  _fx_Nt6option1N10Ast__typ_t t2_opt_1 = v_29->u.TypVarTuple;
                  bool v_34;
                  FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tLN10Ast__typ_t(r2_1, tl1_0, &v_34, 0),
                     _fx_catch_9);
                  if (v_34) {
                     result_0 = false; FX_BREAK(_fx_catch_9);
                  }
                  else {
                     bool ok_1;
                     if ((t2_opt_1 != 0) + 1 == 2) {
                        _fx_FPB1N10Ast__typ_t __lambda___0 = {0};
                        _fx_N10Ast__typ_t t2__1 = t2_opt_1->u.Some;
                        _fx_M13Ast_typecheckFM7make_fpFPB1N10Ast__typ_t4R10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBN10Ast__typ_trLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
                           &loc_2, rec_undo_stack_ref_0, t2__1, undo_stack_ref_0, &__lambda___0);
                        FX_CALL(_fx_M13Ast_typecheckFM3allB2LN10Ast__typ_tFPB1N10Ast__typ_t(tl1_0, &__lambda___0, &ok_1, 0),
                           _fx_catch_8);

                     _fx_catch_8: ;
                        FX_FREE_FP(&__lambda___0);
                     }
                     else {
                        ok_1 = true;
                     }
                     FX_CHECK_EXN(_fx_catch_9);
                     if (ok_1) {
                        FX_COPY_PTR(r2_1->data, &v_30);
                        _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r2_1, v_30, &v_31);
                        FX_CALL(_fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_31, *undo_stack_0, true, &v_32),
                           _fx_catch_9);
                        _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                        FX_COPY_PTR(v_32, undo_stack_0);
                        FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t1_2, &v_33), _fx_catch_9);
                        _fx_Nt6option1N10Ast__typ_t* v_35 = &r2_1->data;
                        _fx_free_Nt6option1N10Ast__typ_t(v_35);
                        FX_COPY_PTR(v_33, v_35);
                     }
                     result_0 = ok_1;
                     FX_BREAK(_fx_catch_9);
                  }

               _fx_catch_9: ;
                  if (v_33) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_33);
                  }
                  if (v_32) {
                     _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_32);
                  }
                  _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_31);
                  if (v_30) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_30);
                  }
                  goto _fx_endmatch_7;
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 1) {
         _fx_rNt6option1N10Ast__typ_t r1_1 = t1_2->u.TypVar;
         FX_COPY_PTR(r1_1->data, &v_6);
         if ((v_6 != 0) + 1 == 2) {
            if (FX_REC_VARIANT_TAG(v_6->u.Some) == 4) {
               _fx_N10Ast__typ_t t2_3 = 0;
               _fx_Nt6option1N10Ast__typ_t v_36 = 0;
               _fx_Nt6option1N10Ast__typ_t v_37 = 0;
               FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t2_2, &t2_3, 0), _fx_catch_17);
               int tag_0 = FX_REC_VARIANT_TAG(t2_3);
               if (tag_0 == 1) {
                  _fx_rNt6option1N10Ast__typ_t r2_2 = t2_3->u.TypVar;
                  FX_COPY_PTR(r2_2->data, &v_36);
                  if ((v_36 != 0) + 1 == 2) {
                     if (FX_REC_VARIANT_TAG(v_36->u.Some) == 4) {
                        _fx_Nt6option1N10Ast__typ_t v_38 = 0;
                        _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_39 = {0};
                        _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_40 = 0;
                        _fx_Nt6option1N10Ast__typ_t v_41 = 0;
                        bool v_42;
                        FX_CALL(
                           _fx_M13Ast_typecheckFM6__ne__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(r1_1, r2_2, &v_42,
                              0), _fx_catch_10);
                        if (v_42) {
                           FX_COPY_PTR(r2_2->data, &v_38);
                           _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r2_2, v_38, &v_39);
                           FX_CALL(
                              _fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_39, *undo_stack_0, true, &v_40),
                              _fx_catch_10);
                           _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                           FX_COPY_PTR(v_40, undo_stack_0);
                           FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t1_2, &v_41), _fx_catch_10);
                           _fx_Nt6option1N10Ast__typ_t* v_43 = &r2_2->data;
                           _fx_free_Nt6option1N10Ast__typ_t(v_43);
                           FX_COPY_PTR(v_41, v_43);
                        }
                        result_0 = true;
                        FX_BREAK(_fx_catch_10);

                     _fx_catch_10: ;
                        if (v_41) {
                           _fx_free_Nt6option1N10Ast__typ_t(&v_41);
                        }
                        if (v_40) {
                           _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_40);
                        }
                        _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_39);
                        if (v_38) {
                           _fx_free_Nt6option1N10Ast__typ_t(&v_38);
                        }
                        goto _fx_endmatch_3;
                     }
                  }
               }
               if (tag_0 == 1) {
                  _fx_rNt6option1N10Ast__typ_t r2_3 = t2_3->u.TypVar;
                  FX_COPY_PTR(r2_3->data, &v_37);
                  if ((v_37 != 0) + 1 == 1) {
                     _fx_Nt6option1N10Ast__typ_t v_44 = 0;
                     _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_45 = {0};
                     _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_46 = 0;
                     _fx_Nt6option1N10Ast__typ_t v_47 = 0;
                     FX_COPY_PTR(r2_3->data, &v_44);
                     _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r2_3, v_44, &v_45);
                     FX_CALL(_fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_45, *undo_stack_0, true, &v_46),
                        _fx_catch_11);
                     _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                     FX_COPY_PTR(v_46, undo_stack_0);
                     FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t1_2, &v_47), _fx_catch_11);
                     _fx_Nt6option1N10Ast__typ_t* v_48 = &r2_3->data;
                     _fx_free_Nt6option1N10Ast__typ_t(v_48);
                     FX_COPY_PTR(v_47, v_48);
                     result_0 = true;
                     FX_BREAK(_fx_catch_11);

                  _fx_catch_11: ;
                     if (v_47) {
                        _fx_free_Nt6option1N10Ast__typ_t(&v_47);
                     }
                     if (v_46) {
                        _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_46);
                     }
                     _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_45);
                     if (v_44) {
                        _fx_free_Nt6option1N10Ast__typ_t(&v_44);
                     }
                     goto _fx_endmatch_3;
                  }
               }
               if (tag_0 == 20) {
                  _fx_Nt6option1N10Ast__typ_t v_49 = 0;
                  _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_50 = {0};
                  _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_51 = 0;
                  _fx_Nt6option1N10Ast__typ_t v_52 = 0;
                  FX_COPY_PTR(r1_1->data, &v_49);
                  _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r1_1, v_49, &v_50);
                  FX_CALL(_fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_50, *undo_stack_0, true, &v_51),
                     _fx_catch_12);
                  _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                  FX_COPY_PTR(v_51, undo_stack_0);
                  FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t2_3, &v_52), _fx_catch_12);
                  _fx_Nt6option1N10Ast__typ_t* v_53 = &r1_1->data;
                  _fx_free_Nt6option1N10Ast__typ_t(v_53);
                  FX_COPY_PTR(v_52, v_53);
                  result_0 = true;
                  FX_BREAK(_fx_catch_12);

               _fx_catch_12: ;
                  if (v_52) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_52);
                  }
                  if (v_51) {
                     _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_51);
                  }
                  _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_50);
                  if (v_49) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_49);
                  }
                  goto _fx_endmatch_3;
               }
               if (tag_0 == 24) {
                  _fx_N14Ast__id_info_t v_54 = {0};
                  _fx_R17Ast__defvariant_t v_55 = {0};
                  FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&t2_3->u.TypApp.t1, &loc_2, &v_54, 0),
                     _fx_catch_15);
                  if (v_54.tag == 6) {
                     _fx_copy_R17Ast__defvariant_t(&v_54.u.IdVariant->data, &v_55);
                     _fx_LT2R9Ast__id_tN10Ast__typ_t v_56 = v_55.dvar_cases;
                     if (v_56 != 0) {
                        if (v_56->tl == 0) {
                           if (FX_REC_VARIANT_TAG(v_56->hd.t1) == 20) {
                              _fx_Nt6option1N10Ast__typ_t v_57 = 0;
                              _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_58 = {0};
                              _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_59 = 0;
                              _fx_Nt6option1N10Ast__typ_t v_60 = 0;
                              FX_COPY_PTR(r1_1->data, &v_57);
                              _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r1_1, v_57, &v_58);
                              FX_CALL(
                                 _fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_58, *undo_stack_0, true, &v_59),
                                 _fx_catch_13);
                              _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                              FX_COPY_PTR(v_59, undo_stack_0);
                              FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t2_3, &v_60),
                                 _fx_catch_13);
                              _fx_Nt6option1N10Ast__typ_t* v_61 = &r1_1->data;
                              _fx_free_Nt6option1N10Ast__typ_t(v_61);
                              FX_COPY_PTR(v_60, v_61);
                              result_0 = true;
                              FX_BREAK(_fx_catch_13);

                           _fx_catch_13: ;
                              if (v_60) {
                                 _fx_free_Nt6option1N10Ast__typ_t(&v_60);
                              }
                              if (v_59) {
                                 _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_59);
                              }
                              _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_58);
                              if (v_57) {
                                 _fx_free_Nt6option1N10Ast__typ_t(&v_57);
                              }
                              goto _fx_endmatch_2;
                           }
                        }
                     }
                  }
                  result_0 = false;
                  FX_BREAK(_fx_catch_14);

               _fx_catch_14: ;

               _fx_endmatch_2: ;
                  FX_CHECK_EXN(_fx_catch_15);

               _fx_catch_15: ;
                  _fx_free_R17Ast__defvariant_t(&v_55);
                  _fx_free_N14Ast__id_info_t(&v_54);
                  goto _fx_endmatch_3;
               }
               result_0 = false;
               FX_BREAK(_fx_catch_16);

            _fx_catch_16: ;

            _fx_endmatch_3: ;
               FX_CHECK_EXN(_fx_catch_17);

            _fx_catch_17: ;
               if (v_37) {
                  _fx_free_Nt6option1N10Ast__typ_t(&v_37);
               }
               if (v_36) {
                  _fx_free_Nt6option1N10Ast__typ_t(&v_36);
               }
               if (t2_3) {
                  _fx_free_N10Ast__typ_t(&t2_3);
               }
               goto _fx_endmatch_7;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 1) {
         FX_COPY_PTR(t2_2->u.TypVar->data, &v_7);
         if ((v_7 != 0) + 1 == 2) {
            if (FX_REC_VARIANT_TAG(v_7->u.Some) == 4) {
               _fx_free_N10Ast__typ_t(&t1_1);
               FX_COPY_PTR(t2_2, &t1_1);
               _fx_free_N10Ast__typ_t(&t2_1);
               FX_COPY_PTR(t1_2, &t2_1);
               loc_1 = loc_2;
               goto _fx_endmatch_7;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 18) {
         if (FX_REC_VARIANT_TAG(t1_2) == 18) {
            _fx_N10Ast__typ_t* drt1_0 = &t1_2->u.TypRef;
            _fx_free_N10Ast__typ_t(&t1_1);
            FX_COPY_PTR(*drt1_0, &t1_1);
            _fx_N10Ast__typ_t* drt2_0 = &t2_2->u.TypRef;
            _fx_free_N10Ast__typ_t(&t2_1);
            FX_COPY_PTR(*drt2_0, &t2_1);
            loc_1 = loc_2;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 20) {
         if (FX_REC_VARIANT_TAG(t1_2) == 20) {
            if (_fx_M13Ast_typecheckFM6__eq__B2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
                   t1_2->u.TypRecord, t2_2->u.TypRecord, 0)) {
               result_0 = true; FX_BREAK(_fx_catch_18);  _fx_catch_18: ; goto _fx_endmatch_7;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 20) {
         if (FX_REC_VARIANT_TAG(t2_2) == 20) {
            _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&t1_2->u.TypRecord->data, &v_8);
            if (v_8.t1 == false) {
               _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&t2_2->u.TypRecord->data, &v_9);
               if (v_9.t1 == true) {
                  _fx_free_N10Ast__typ_t(&t1_1);
                  FX_COPY_PTR(t2_2, &t1_1);
                  _fx_free_N10Ast__typ_t(&t2_1);
                  FX_COPY_PTR(t1_2, &t2_1);
                  loc_1 = loc_2;
                  goto _fx_endmatch_7;
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 20) {
         if (FX_REC_VARIANT_TAG(t1_2) == 20) {
            _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_62 = {0};
            _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_63 = {0};
            _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_64 = {0};
            _fx_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB
               v_65 = {0};
            _fx_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB
               v_66 = 0;
            _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_67 = {0};
            _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB r1_2 = t1_2->u.TypRecord;
            _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB r2_4 = t2_2->u.TypRecord;
            _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&r1_2->data, &v_62);
            _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&r2_4->data, &v_63);
            bool ok_2;
            if (v_63.t1 == true) {
               if (v_62.t1 == true) {
                  _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems1_0 = 0;
                  _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems2_0 = 0;
                  _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems1_1 = v_62.t0;
                  _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems2_1 = v_63.t0;
                  int_ v_68;
                  FX_CALL(
                     _fx_M13Ast_typecheckFM8length1_i1LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(relems1_1,
                        &v_68, 0), _fx_catch_20);
                  int_ v_69;
                  FX_CALL(
                     _fx_M13Ast_typecheckFM8length1_i1LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(relems2_1,
                        &v_69, 0), _fx_catch_20);
                  if (v_68 == v_69) {
                     bool __fold_result___0 = true;
                     FX_COPY_PTR(relems1_1, &relems1_0);
                     _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_0 = relems1_0;
                     FX_COPY_PTR(relems2_1, &relems2_0);
                     _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_1 = relems2_0;
                     for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl) {
                        _fx_R16Ast__val_flags_t f1_0 = {0};
                        _fx_N10Ast__typ_t t1_3 = 0;
                        _fx_R16Ast__val_flags_t f2_0 = {0};
                        _fx_N10Ast__typ_t t2_4 = 0;
                        _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___0 = &lst_1->hd;
                        _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___1 = &lst_0->hd;
                        _fx_copy_R16Ast__val_flags_t(&__pat___1->t0, &f1_0);
                        _fx_R9Ast__id_t n1_0 = __pat___1->t1;
                        FX_COPY_PTR(__pat___1->t2, &t1_3);
                        _fx_copy_R16Ast__val_flags_t(&__pat___0->t0, &f2_0);
                        _fx_R9Ast__id_t n2_0 = __pat___0->t1;
                        FX_COPY_PTR(__pat___0->t2, &t2_4);
                        bool v_70;
                        bool res_3;
                        FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&n1_0, &n2_0, &res_3, 0), _fx_catch_19);
                        bool t_0;
                        if (res_3) {
                           FX_CALL(
                              _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(t1_3, t2_4, &loc_2,
                                 &t_0, fx_fv), _fx_catch_19);
                        }
                        else {
                           t_0 = false;
                        }
                        if (t_0) {
                           v_70 = f1_0.val_flag_mutable == f2_0.val_flag_mutable;
                        }
                        else {
                           v_70 = false;
                        }
                        if (!v_70) {
                           __fold_result___0 = false; FX_BREAK(_fx_catch_19);
                        }

                     _fx_catch_19: ;
                        if (t2_4) {
                           _fx_free_N10Ast__typ_t(&t2_4);
                        }
                        _fx_free_R16Ast__val_flags_t(&f2_0);
                        if (t1_3) {
                           _fx_free_N10Ast__typ_t(&t1_3);
                        }
                        _fx_free_R16Ast__val_flags_t(&f1_0);
                        FX_CHECK_BREAK();
                        FX_CHECK_EXN(_fx_catch_20);
                     }
                     int s_0 = !lst_0 + !lst_1;
                     FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_20);
                     ok_2 = __fold_result___0;
                  }
                  else {
                     ok_2 = false;
                  }

               _fx_catch_20: ;
                  if (relems2_0) {
                     _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems2_0);
                  }
                  if (relems1_0) {
                     _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems1_0);
                  }
                  goto _fx_endmatch_4;
               }
            }
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems1_2 = 0;
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems2_2 = 0;
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems2_3 = v_63.t0;
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems1_3 = v_62.t0;
            bool __fold_result___1 = true;
            FX_COPY_PTR(relems1_3, &relems1_2);
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_2 = relems1_2;
            for (; lst_2; lst_2 = lst_2->tl) {
               _fx_N10Ast__typ_t t1_4 = 0;
               _fx_N10Ast__exp_t v1_0 = 0;
               _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems2_4 = 0;
               _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___2 = &lst_2->hd;
               _fx_R9Ast__id_t n1_1 = __pat___2->t1;
               FX_COPY_PTR(__pat___2->t2, &t1_4);
               FX_COPY_PTR(__pat___2->t3, &v1_0);
               bool v_71;
               bool res_4;
               if (FX_REC_VARIANT_TAG(v1_0) == 1) {
                  res_4 = false;
               }
               else {
                  res_4 = true;
               }
               FX_CHECK_EXN(_fx_catch_22);
               if (res_4) {
                  v_71 = true;
               }
               else {
                  bool __fold_result___2 = false;
                  FX_COPY_PTR(relems2_3, &relems2_4);
                  _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_3 = relems2_4;
                  for (; lst_3; lst_3 = lst_3->tl) {
                     _fx_N10Ast__typ_t t2_5 = 0;
                     _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___3 = &lst_3->hd;
                     _fx_R9Ast__id_t n2_1 = __pat___3->t1;
                     FX_COPY_PTR(__pat___3->t2, &t2_5);
                     bool v_72;
                     bool res_5;
                     FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&n1_1, &n2_1, &res_5, 0), _fx_catch_21);
                     if (res_5) {
                        FX_CALL(
                           _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(t1_4, t2_5, &loc_2,
                              &v_72, fx_fv), _fx_catch_21);
                     }
                     else {
                        v_72 = false;
                     }
                     if (v_72) {
                        __fold_result___2 = true; FX_BREAK(_fx_catch_21);
                     }

                  _fx_catch_21: ;
                     if (t2_5) {
                        _fx_free_N10Ast__typ_t(&t2_5);
                     }
                     FX_CHECK_BREAK();
                     FX_CHECK_EXN(_fx_catch_22);
                  }
                  v_71 = __fold_result___2;
               }
               if (!v_71) {
                  __fold_result___1 = false; FX_BREAK(_fx_catch_22);
               }

            _fx_catch_22: ;
               if (relems2_4) {
                  _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems2_4);
               }
               if (v1_0) {
                  _fx_free_N10Ast__exp_t(&v1_0);
               }
               if (t1_4) {
                  _fx_free_N10Ast__typ_t(&t1_4);
               }
               FX_CHECK_BREAK();
               FX_CHECK_EXN(_fx_catch_25);
            }
            bool have_all_matches_0 = __fold_result___1;
            bool __fold_result___3 = true;
            FX_COPY_PTR(relems2_3, &relems2_2);
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_4 = relems2_2;
            for (; lst_4; lst_4 = lst_4->tl) {
               _fx_N10Ast__typ_t t2_6 = 0;
               _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems1_4 = 0;
               _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___4 = &lst_4->hd;
               _fx_R9Ast__id_t n2_2 = __pat___4->t1;
               FX_COPY_PTR(__pat___4->t2, &t2_6);
               bool __fold_result___4 = false;
               FX_COPY_PTR(relems1_3, &relems1_4);
               _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_5 = relems1_4;
               for (; lst_5; lst_5 = lst_5->tl) {
                  _fx_N10Ast__typ_t t1_5 = 0;
                  _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___5 = &lst_5->hd;
                  _fx_R9Ast__id_t n1_2 = __pat___5->t1;
                  FX_COPY_PTR(__pat___5->t2, &t1_5);
                  bool v_73;
                  bool res_6;
                  FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&n1_2, &n2_2, &res_6, 0), _fx_catch_23);
                  if (res_6) {
                     FX_CALL(
                        _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(t1_5, t2_6, &loc_2, &v_73,
                           fx_fv), _fx_catch_23);
                  }
                  else {
                     v_73 = false;
                  }
                  if (v_73) {
                     __fold_result___4 = true; FX_BREAK(_fx_catch_23);
                  }

               _fx_catch_23: ;
                  if (t1_5) {
                     _fx_free_N10Ast__typ_t(&t1_5);
                  }
                  FX_CHECK_BREAK();
                  FX_CHECK_EXN(_fx_catch_24);
               }
               if (!__fold_result___4) {
                  __fold_result___3 = false; FX_BREAK(_fx_catch_24);
               }

            _fx_catch_24: ;
               if (relems1_4) {
                  _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems1_4);
               }
               if (t2_6) {
                  _fx_free_N10Ast__typ_t(&t2_6);
               }
               FX_CHECK_BREAK();
               FX_CHECK_EXN(_fx_catch_25);
            }
            bool have_all_matches2_0 = __fold_result___3;
            bool t_1;
            if (have_all_matches_0) {
               t_1 = have_all_matches2_0;
            }
            else {
               t_1 = false;
            }
            if (t_1) {
               int_ v_74;
               FX_CALL(
                  _fx_M13Ast_typecheckFM8length1_i1LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(relems1_3, &v_74,
                     0), _fx_catch_25);
               int_ v_75;
               FX_CALL(
                  _fx_M13Ast_typecheckFM8length1_i1LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(relems2_3, &v_75,
                     0), _fx_catch_25);
               ok_2 = v_74 >= v_75;
            }
            else {
               ok_2 = false;
            }

         _fx_catch_25: ;
            if (relems2_2) {
               _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems2_2);
            }
            if (relems1_2) {
               _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems1_2);
            }

         _fx_endmatch_4: ;
            FX_CHECK_EXN(_fx_catch_26);
            if (ok_2) {
               _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&r2_4->data, &v_64);
               _fx_make_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
                  r2_4, &v_64, &v_65);
               FX_CALL(
                  _fx_cons_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
                     &v_65, *rec_undo_stack_0, true, &v_66), _fx_catch_26);
               _fx_free_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
                  rec_undo_stack_0);
               FX_COPY_PTR(v_66, rec_undo_stack_0);
               _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&r1_2->data, &v_67);
               _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* v_76 = &r2_4->data;
               _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(v_76);
               _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_67, v_76);
            }
            result_0 = ok_2;
            FX_BREAK(_fx_catch_26);

         _fx_catch_26: ;
            _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_67);
            if (v_66) {
               _fx_free_LT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
                  &v_66);
            }
            _fx_free_T2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
               &v_65);
            _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_64);
            _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_63);
            _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_62);
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 19) {
         _fx_T2iN10Ast__typ_t* vcase_2 = &t2_2->u.TypArray;
         if (FX_REC_VARIANT_TAG(t1_2) == 19) {
            _fx_T2iN10Ast__typ_t* vcase_3 = &t1_2->u.TypArray;
            if (vcase_3->t0 == vcase_2->t0) {
               _fx_N10Ast__typ_t* et1_2 = &vcase_3->t1;
               _fx_free_N10Ast__typ_t(&t1_1);
               FX_COPY_PTR(*et1_2, &t1_1);
               _fx_N10Ast__typ_t* et2_2 = &vcase_2->t1;
               _fx_free_N10Ast__typ_t(&t2_1);
               FX_COPY_PTR(*et2_2, &t2_1);
               loc_1 = loc_2;
            }
            else {
               result_0 = false; FX_BREAK(_fx_catch_27);
            }

         _fx_catch_27: ;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 1) {
         if (FX_REC_VARIANT_TAG(t1_2) == 1) {
            _fx_rNt6option1N10Ast__typ_t r1_3 = t1_2->u.TypVar;
            FX_COPY_PTR(r1_3->data, &v_10);
            if ((v_10 != 0) + 1 == 2) {
               _fx_N10Ast__typ_t v_77 = v_10->u.Some;
               if (FX_REC_VARIANT_TAG(v_77) == 3) {
                  _fx_rNt6option1N10Ast__typ_t r2_5 = t2_2->u.TypVar;
                  FX_COPY_PTR(r2_5->data, &v_11);
                  if ((v_11 != 0) + 1 == 2) {
                     _fx_N10Ast__typ_t v_78 = v_11->u.Some;
                     if (FX_REC_VARIANT_TAG(v_78) == 3) {
                        _fx_Nt6option1N10Ast__typ_t v_79 = 0;
                        _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_80 = {0};
                        _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_81 = 0;
                        _fx_Nt6option1N10Ast__typ_t v_82 = 0;
                        bool v_83 =
                           _fx_M13Ast_typecheckFM6__eq__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(r1_3, r2_5, 0);
                        if (v_83) {
                           result_0 = true; FX_BREAK(_fx_catch_28);
                        }
                        else {
                           bool v_84;
                           bool res_7;
                           FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r2_5, t1_2, &res_7, 0),
                              _fx_catch_28);
                           if (res_7) {
                              v_84 = true;
                           }
                           else {
                              FX_CALL(
                                 _fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r1_3, t2_2, &v_84, 0),
                                 _fx_catch_28);
                           }
                           if (v_84) {
                              result_0 = false; FX_BREAK(_fx_catch_28);
                           }
                           else {
                              bool v_85;
                              FX_CALL(
                                 _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(
                                    v_77->u.TypVarArray, v_78->u.TypVarArray, &loc_2, &v_85, fx_fv), _fx_catch_28);
                              if (v_85) {
                                 FX_COPY_PTR(r2_5->data, &v_79);
                                 _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r2_5, v_79, &v_80);
                                 FX_CALL(
                                    _fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_80, *undo_stack_0, true,
                                       &v_81), _fx_catch_28);
                                 _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                                 FX_COPY_PTR(v_81, undo_stack_0);
                                 FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t1_2, &v_82),
                                    _fx_catch_28);
                                 _fx_Nt6option1N10Ast__typ_t* v_86 = &r2_5->data;
                                 _fx_free_Nt6option1N10Ast__typ_t(v_86);
                                 FX_COPY_PTR(v_82, v_86);
                                 result_0 = true;
                                 FX_BREAK(_fx_catch_28);
                              }
                              else {
                                 result_0 = false; FX_BREAK(_fx_catch_28);
                              }
                           }
                        }

                     _fx_catch_28: ;
                        if (v_82) {
                           _fx_free_Nt6option1N10Ast__typ_t(&v_82);
                        }
                        if (v_81) {
                           _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_81);
                        }
                        _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_80);
                        if (v_79) {
                           _fx_free_Nt6option1N10Ast__typ_t(&v_79);
                        }
                        goto _fx_endmatch_7;
                     }
                  }
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 1) {
         FX_COPY_PTR(t1_2->u.TypVar->data, &v_12);
         if ((v_12 != 0) + 1 == 2) {
            if (FX_REC_VARIANT_TAG(v_12->u.Some) == 3) {
               if (FX_REC_VARIANT_TAG(t2_2) == 1) {
                  FX_COPY_PTR(t2_2->u.TypVar->data, &v_13);
                  if ((v_13 != 0) + 1 == 2) {
                     _fx_N10Ast__typ_t* t2__2 = &v_13->u.Some;
                     _fx_free_N10Ast__typ_t(&t1_1);
                     FX_COPY_PTR(*t2__2, &t1_1);
                     _fx_free_N10Ast__typ_t(&t2_1);
                     FX_COPY_PTR(t1_2, &t2_1);
                     loc_1 = loc_2;
                     goto _fx_endmatch_7;
                  }
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 1) {
         if (FX_REC_VARIANT_TAG(t2_2) == 19) {
            FX_COPY_PTR(t1_2->u.TypVar->data, &v_14);
            if ((v_14 != 0) + 1 == 2) {
               if (FX_REC_VARIANT_TAG(v_14->u.Some) == 3) {
                  _fx_free_N10Ast__typ_t(&t1_1);
                  FX_COPY_PTR(t2_2, &t1_1);
                  _fx_free_N10Ast__typ_t(&t2_1);
                  FX_COPY_PTR(t1_2, &t2_1);
                  loc_1 = loc_2;
                  goto _fx_endmatch_7;
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 1) {
         if (FX_REC_VARIANT_TAG(t1_2) == 19) {
            _fx_N10Ast__typ_t et1_3 = t1_2->u.TypArray.t1;
            _fx_rNt6option1N10Ast__typ_t r2_6 = t2_2->u.TypVar;
            FX_COPY_PTR(r2_6->data, &v_15);
            if ((v_15 != 0) + 1 == 2) {
               _fx_N10Ast__typ_t v_87 = v_15->u.Some;
               if (FX_REC_VARIANT_TAG(v_87) == 3) {
                  _fx_Nt6option1N10Ast__typ_t v_88 = 0;
                  _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_89 = {0};
                  _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_90 = 0;
                  _fx_Nt6option1N10Ast__typ_t v_91 = 0;
                  bool v_92;
                  FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r2_6, et1_3, &v_92, 0),
                     _fx_catch_29);
                  if (v_92) {
                     result_0 = false; FX_BREAK(_fx_catch_29);
                  }
                  else {
                     bool v_93;
                     FX_CALL(
                        _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(et1_3,
                           v_87->u.TypVarArray, &loc_2, &v_93, fx_fv), _fx_catch_29);
                     if (v_93) {
                        FX_COPY_PTR(r2_6->data, &v_88);
                        _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r2_6, v_88, &v_89);
                        FX_CALL(_fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_89, *undo_stack_0, true, &v_90),
                           _fx_catch_29);
                        _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                        FX_COPY_PTR(v_90, undo_stack_0);
                        FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t1_2, &v_91), _fx_catch_29);
                        _fx_Nt6option1N10Ast__typ_t* v_94 = &r2_6->data;
                        _fx_free_Nt6option1N10Ast__typ_t(v_94);
                        FX_COPY_PTR(v_91, v_94);
                        result_0 = true;
                        FX_BREAK(_fx_catch_29);
                     }
                     else {
                        result_0 = false; FX_BREAK(_fx_catch_29);
                     }
                  }

               _fx_catch_29: ;
                  if (v_91) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_91);
                  }
                  if (v_90) {
                     _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_90);
                  }
                  _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_89);
                  if (v_88) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_88);
                  }
                  goto _fx_endmatch_7;
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 24) {
         _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_4 = &t2_2->u.TypApp;
         if (FX_REC_VARIANT_TAG(t1_2) == 24) {
            _fx_N10Ast__typ_t t1_6 = 0;
            _fx_N10Ast__typ_t t2_7 = 0;
            _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_5 = &t1_2->u.TypApp;
            _fx_LN10Ast__typ_t args1_0 = vcase_5->t0;
            _fx_LN10Ast__typ_t args2_0 = vcase_4->t0;
            bool res_8;
            FX_CALL(_fx_M13Ast_typecheckFM6__ne__B2R9Ast__id_tR9Ast__id_t(&vcase_5->t1, &vcase_4->t1, &res_8, 0), _fx_catch_32);
            if (res_8) {
               result_0 = false; FX_BREAK(_fx_catch_32);
            }
            else {
               if (args1_0 == 0) {
                  FX_COPY_PTR(_fx_g22Ast_typecheck__TypVoid, &t1_6); goto _fx_endmatch_5;
               }
               if (args1_0 != 0) {
                  if (args1_0->tl == 0) {
                     FX_COPY_PTR(args1_0->hd, &t1_6); goto _fx_endmatch_5;
                  }
               }
               FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(args1_0, &t1_6), _fx_catch_30);

            _fx_catch_30: ;

            _fx_endmatch_5: ;
               FX_CHECK_EXN(_fx_catch_32);
               if (args2_0 == 0) {
                  FX_COPY_PTR(_fx_g22Ast_typecheck__TypVoid, &t2_7); goto _fx_endmatch_6;
               }
               if (args2_0 != 0) {
                  if (args2_0->tl == 0) {
                     FX_COPY_PTR(args2_0->hd, &t2_7); goto _fx_endmatch_6;
                  }
               }
               FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(args2_0, &t2_7), _fx_catch_31);

            _fx_catch_31: ;

            _fx_endmatch_6: ;
               FX_CHECK_EXN(_fx_catch_32);
               _fx_free_N10Ast__typ_t(&t1_1);
               FX_COPY_PTR(t1_6, &t1_1);
               _fx_free_N10Ast__typ_t(&t2_1);
               FX_COPY_PTR(t2_7, &t2_1);
               loc_1 = loc_2;
            }

         _fx_catch_32: ;
            if (t2_7) {
               _fx_free_N10Ast__typ_t(&t2_7);
            }
            if (t1_6) {
               _fx_free_N10Ast__typ_t(&t1_6);
            }
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 1) {
         if (FX_REC_VARIANT_TAG(t1_2) == 1) {
            if (_fx_M13Ast_typecheckFM6__eq__B2rNt6option1N10Ast__typ_trNt6option1N10Ast__typ_t(t1_2->u.TypVar, t2_2->u.TypVar,
                   0)) {
               result_0 = true; FX_BREAK(_fx_catch_33);  _fx_catch_33: ; goto _fx_endmatch_7;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 1) {
         FX_COPY_PTR(t1_2->u.TypVar->data, &v_16);
         if ((v_16 != 0) + 1 == 2) {
            _fx_N10Ast__typ_t* t1__0 = &v_16->u.Some;
            _fx_free_N10Ast__typ_t(&t1_1);
            FX_COPY_PTR(*t1__0, &t1_1);
            _fx_free_N10Ast__typ_t(&t2_1);
            FX_COPY_PTR(t2_2, &t2_1);
            loc_1 = loc_2;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 1) {
         FX_COPY_PTR(t2_2->u.TypVar->data, &v_17);
         if ((v_17 != 0) + 1 == 2) {
            _fx_free_N10Ast__typ_t(&t1_1);
            FX_COPY_PTR(t1_2, &t1_1);
            _fx_N10Ast__typ_t* t2__3 = &v_17->u.Some;
            _fx_free_N10Ast__typ_t(&t2_1);
            FX_COPY_PTR(*t2__3, &t2_1);
            loc_1 = loc_2;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 1) {
         _fx_rNt6option1N10Ast__typ_t r1_4 = t1_2->u.TypVar;
         FX_COPY_PTR(r1_4->data, &v_18);
         if ((v_18 != 0) + 1 == 1) {
            bool v_95;
            FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r1_4, t2_2, &v_95, 0), _fx_catch_35);
            if (v_95) {
               result_0 = false; FX_BREAK(_fx_catch_35);
            }
            else {
               if (FX_REC_VARIANT_TAG(t2_2) != 22) {
                  _fx_Nt6option1N10Ast__typ_t v_96 = 0;
                  _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_97 = {0};
                  _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_98 = 0;
                  _fx_Nt6option1N10Ast__typ_t v_99 = 0;
                  FX_COPY_PTR(r1_4->data, &v_96);
                  _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r1_4, v_96, &v_97);
                  FX_CALL(_fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_97, *undo_stack_0, true, &v_98),
                     _fx_catch_34);
                  _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                  FX_COPY_PTR(v_98, undo_stack_0);
                  FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t2_2, &v_99), _fx_catch_34);
                  _fx_Nt6option1N10Ast__typ_t* v_100 = &r1_4->data;
                  _fx_free_Nt6option1N10Ast__typ_t(v_100);
                  FX_COPY_PTR(v_99, v_100);

               _fx_catch_34: ;
                  if (v_99) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_99);
                  }
                  if (v_98) {
                     _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_98);
                  }
                  _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_97);
                  if (v_96) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_96);
                  }
               }
               FX_CHECK_EXN(_fx_catch_35);
               result_0 = true;
               FX_BREAK(_fx_catch_35);
            }

         _fx_catch_35: ;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 1) {
         _fx_rNt6option1N10Ast__typ_t r2_7 = t2_2->u.TypVar;
         FX_COPY_PTR(r2_7->data, &v_19);
         if ((v_19 != 0) + 1 == 1) {
            bool v_101;
            FX_CALL(_fx_M13Ast_typecheckFM6occursB2rNt6option1N10Ast__typ_tN10Ast__typ_t(r2_7, t1_2, &v_101, 0), _fx_catch_37);
            if (v_101) {
               result_0 = false; FX_BREAK(_fx_catch_37);
            }
            else {
               if (FX_REC_VARIANT_TAG(t1_2) != 22) {
                  _fx_Nt6option1N10Ast__typ_t v_102 = 0;
                  _fx_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_103 = {0};
                  _fx_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t v_104 = 0;
                  _fx_Nt6option1N10Ast__typ_t v_105 = 0;
                  FX_COPY_PTR(r2_7->data, &v_102);
                  _fx_make_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(r2_7, v_102, &v_103);
                  FX_CALL(_fx_cons_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_103, *undo_stack_0, true, &v_104),
                     _fx_catch_36);
                  _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(undo_stack_0);
                  FX_COPY_PTR(v_104, undo_stack_0);
                  FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t1_2, &v_105), _fx_catch_36);
                  _fx_Nt6option1N10Ast__typ_t* v_106 = &r2_7->data;
                  _fx_free_Nt6option1N10Ast__typ_t(v_106);
                  FX_COPY_PTR(v_105, v_106);

               _fx_catch_36: ;
                  if (v_105) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_105);
                  }
                  if (v_104) {
                     _fx_free_LT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_104);
                  }
                  _fx_free_T2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(&v_103);
                  if (v_102) {
                     _fx_free_Nt6option1N10Ast__typ_t(&v_102);
                  }
               }
               FX_CHECK_EXN(_fx_catch_37);
               result_0 = true;
               FX_BREAK(_fx_catch_37);
            }

         _fx_catch_37: ;
            goto _fx_endmatch_7;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 22) {
         result_0 = true; FX_BREAK(_fx_catch_38);  _fx_catch_38: ; goto _fx_endmatch_7;
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 22) {
         result_0 = true; FX_BREAK(_fx_catch_39);  _fx_catch_39: ; goto _fx_endmatch_7;
      }
      bool res_9;
      if (FX_REC_VARIANT_TAG(t1_2) == 25) {
         res_9 = true;
      }
      else if (FX_REC_VARIANT_TAG(t2_2) == 25) {
         res_9 = true;
      }
      else {
         res_9 = false;
      }
      FX_CHECK_EXN(_fx_catch_42);
      if (res_9) {
         result_0 = false; FX_BREAK(_fx_catch_40);  _fx_catch_40: ; goto _fx_endmatch_7;
      }
      result_0 = false;
      FX_BREAK(_fx_catch_41);

   _fx_catch_41: ;

   _fx_endmatch_7: ;
      FX_CHECK_EXN(_fx_catch_42);

   _fx_catch_42: ;
      if (v_19) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_19);
      }
      if (v_18) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_18);
      }
      if (v_17) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_17);
      }
      if (v_16) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_16);
      }
      if (v_15) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_15);
      }
      if (v_14) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_14);
      }
      if (v_13) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_13);
      }
      if (v_12) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_12);
      }
      if (v_11) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_11);
      }
      if (v_10) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_10);
      }
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_9);
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_8);
      if (v_7) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_7);
      }
      if (v_6) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_6);
      }
      if (v_5) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_5);
      }
      if (v_4) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_4);
      }
      if (v_3) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_3);
      }
      if (v_2) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_2);
      }
      if (v_1) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_1);
      }
      if (v_0) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_0);
      }
      if (t2_2) {
         _fx_free_N10Ast__typ_t(&t2_2);
      }
      if (t1_2) {
         _fx_free_N10Ast__typ_t(&t1_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = result_0;

_fx_cleanup: ;
   FX_FREE_FP(&maybe_unify__0);
   if (t1_1) {
      _fx_free_N10Ast__typ_t(&t1_1);
   }
   if (t2_1) {
      _fx_free_N10Ast__typ_t(&t2_1);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t2rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      arg0,
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* arg1,
   struct _fx_FPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t_cldata_t,
      _fx_free_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t,
      _fx_M13Ast_typecheckFM12maybe_unify_B3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t);
   FX_COPY_PTR(arg0, &fcv->t0);
   FX_COPY_PTR(arg1, &fcv->t1);
   return 0;
}

static int _fx_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t(struct _fx_N10Ast__typ_t_data_t* t_0, bool* fx_result, void* fx_fv)
{
   _fx_FPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t maybe_unify__0 = {0};
   int fx_status = 0;
   _fx_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t_cldata_t*)fx_fv;
   _fx_M13Ast_typecheckFM7make_fpFPB3N10Ast__typ_tN10Ast__typ_tR10Ast__loc_t2rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBrLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
      cv_0->t1, cv_0->t3, &maybe_unify__0);
   FX_CALL(maybe_unify__0.fp(cv_0->t2, t_0, &cv_0->t0, fx_result, maybe_unify__0.fcv), _fx_cleanup);

_fx_cleanup: ;
   FX_FREE_FP(&maybe_unify__0);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPB1N10Ast__typ_t4R10Ast__loc_trLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBN10Ast__typ_trLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_rLT2rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tBT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB_data_t*
      arg1,
   struct _fx_N10Ast__typ_t_data_t* arg2,
   struct _fx_rLT2rNt6option1N10Ast__typ_tNt6option1N10Ast__typ_t_data_t* arg3,
   struct _fx_FPB1N10Ast__typ_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t_cldata_t,
      _fx_free_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t, _fx_M13Ast_typecheckFM10__lambda__B1N10Ast__typ_t);
   fcv->t0 = *arg0;
   FX_COPY_PTR(arg1, &fcv->t1);
   FX_COPY_PTR(arg2, &fcv->t2);
   FX_COPY_PTR(arg3, &fcv->t3);
   return 0;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   struct _fx_R10Ast__loc_t* loc_0,
   fx_str_t* msg_0,
   void* fx_fv)
{
   fx_exn_t v_0 = {0};
   int fx_status = 0;
   bool v_1;
   FX_CALL(_fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t1_0, t2_0, loc_0, true, &v_1, 0),
      _fx_cleanup);
   if (!v_1) {
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, msg_0, &v_0, 0), _fx_cleanup); FX_THROW(&v_0, false, _fx_cleanup);
   }

_fx_cleanup: ;
   fx_free_exn(&v_0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM12coerce_typesNt6option1N10Ast__typ_t6N10Ast__typ_tN10Ast__typ_tBBBR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   bool allow_tuples_0,
   bool allow_fp_0,
   bool is_shift_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   fx_exn_t exn_0 = {0};
   int fx_status = 0;
   int_ safe_max_ubits_0;
   if (_fx_g12Options__opt.arch64) {
      safe_max_ubits_0 = 32;
   }
   else {
      safe_max_ubits_0 = 16;
   }
   _fx_N10Ast__typ_t v_0 = 0;
   _fx_N10Ast__typ_t v_1 = 0;
   _fx_N10Ast__typ_t v_2 = 0;
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t1_0, &v_0, 0), _fx_catch_0);
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t2_0, &v_1, 0), _fx_catch_0);
   FX_CALL(
      _fx_M13Ast_typecheckFM13coerce_types_N10Ast__typ_t7N10Ast__typ_tN10Ast__typ_tBBBR10Ast__loc_ti(v_0, v_1, allow_fp_0,
         allow_tuples_0, is_shift_0, loc_0, safe_max_ubits_0, &v_2, 0), _fx_catch_0);
   FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(v_2, fx_result), _fx_catch_0);

_fx_catch_0: ;
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   if (v_1) {
      _fx_free_N10Ast__typ_t(&v_1);
   }
   if (v_2) {
      _fx_free_N10Ast__typ_t(&v_2);
   }
   if (fx_status < 0) {
      fx_exn_get_and_reset(fx_status, &exn_0);
      fx_status = 0;
      if (*fx_result) {
         _fx_free_Nt6option1N10Ast__typ_t(fx_result);
      }
      if (exn_0.tag == _FX_EXN_E17Ast__CompileError) {
         FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, fx_result);
      }
      else {
         FX_RETHROW(&exn_0, _fx_cleanup);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }

_fx_cleanup: ;
   fx_free_exn(&exn_0);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM13coerce_types_N10Ast__typ_t7N10Ast__typ_tN10Ast__typ_tBBBR10Ast__loc_ti(
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   bool allow_fp_0,
   bool allow_tuples_0,
   bool is_shift_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ safe_max_ubits_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t result_0 = 0;
   _fx_N10Ast__typ_t t1_1 = 0;
   _fx_N10Ast__typ_t t2_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_COPY_PTR(t1_0, &t1_1);
   FX_COPY_PTR(t2_0, &t2_1);
   for (;;) {
      _fx_N10Ast__typ_t t1_2 = 0;
      _fx_N10Ast__typ_t t2_2 = 0;
      FX_COPY_PTR(t1_1, &t1_2);
      FX_COPY_PTR(t2_1, &t2_2);
      if (FX_REC_VARIANT_TAG(t1_2) == 5) {
         if (FX_REC_VARIANT_TAG(t2_2) == 5) {
            _fx_free_N10Ast__typ_t(&result_0);
            FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0);
            FX_BREAK(_fx_catch_0);

         _fx_catch_0: ;
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 6) {
         if (FX_REC_VARIANT_TAG(t1_2) == 6) {
            _fx_N10Ast__typ_t result_1 = 0;
            int_ b_0 = fx_maxi(t1_2->u.TypSInt, t2_2->u.TypSInt);
            if (b_0 <= 32) {
               _fx_free_N10Ast__typ_t(&result_0); FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0); FX_BREAK(_fx_catch_1);
            }
            else {
               FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(64, &result_1), _fx_catch_1);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_1, &result_0);
               FX_BREAK(_fx_catch_1);
            }

         _fx_catch_1: ;
            if (result_1) {
               _fx_free_N10Ast__typ_t(&result_1);
            }
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 7) {
         if (FX_REC_VARIANT_TAG(t1_2) == 7) {
            _fx_N10Ast__typ_t result_2 = 0;
            int_ b_1 = fx_maxi(t1_2->u.TypUInt, t2_2->u.TypUInt);
            if (b_1 <= safe_max_ubits_0) {
               _fx_free_N10Ast__typ_t(&result_0); FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0); FX_BREAK(_fx_catch_2);
            }
            else {
               FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(b_1, &result_2), _fx_catch_2);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_2, &result_0);
               FX_BREAK(_fx_catch_2);
            }

         _fx_catch_2: ;
            if (result_2) {
               _fx_free_N10Ast__typ_t(&result_2);
            }
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 5) {
         if (FX_REC_VARIANT_TAG(t2_2) == 6) {
            _fx_N10Ast__typ_t result_3 = 0;
            int_ b_2 = t2_2->u.TypSInt;
            if (b_2 <= 32) {
               _fx_free_N10Ast__typ_t(&result_0); FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0); FX_BREAK(_fx_catch_3);
            }
            else {
               FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(b_2, &result_3), _fx_catch_3);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_3, &result_0);
               FX_BREAK(_fx_catch_3);
            }

         _fx_catch_3: ;
            if (result_3) {
               _fx_free_N10Ast__typ_t(&result_3);
            }
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 5) {
         if (FX_REC_VARIANT_TAG(t2_2) == 7) {
            fx_exn_t v_0 = {0};
            if (t2_2->u.TypUInt <= safe_max_ubits_0) {
               _fx_free_N10Ast__typ_t(&result_0); FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0); FX_BREAK(_fx_catch_4);
            }
            else {
               fx_str_t slit_0 =
                  FX_MAKE_STR("implicit type coercion for (int, uint32/uint64) pair is not allowed; use explicit type cast");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_0, &v_0, 0), _fx_catch_4);
               FX_THROW(&v_0, false, _fx_catch_4);
            }

         _fx_catch_4: ;
            fx_free_exn(&v_0);
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 5) {
         if (FX_REC_VARIANT_TAG(t1_2) == 6) {
            _fx_N10Ast__typ_t result_4 = 0;
            _fx_N10Ast__typ_t result_5 = 0;
            int_ b_3 = t1_2->u.TypSInt;
            if (is_shift_0) {
               FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(b_3, &result_4), _fx_catch_5);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_4, &result_0);
               FX_BREAK(_fx_catch_5);
            }
            else if (b_3 <= 32) {
               _fx_free_N10Ast__typ_t(&result_0); FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0); FX_BREAK(_fx_catch_5);
            }
            else {
               FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(b_3, &result_5), _fx_catch_5);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_5, &result_0);
               FX_BREAK(_fx_catch_5);
            }

         _fx_catch_5: ;
            if (result_5) {
               _fx_free_N10Ast__typ_t(&result_5);
            }
            if (result_4) {
               _fx_free_N10Ast__typ_t(&result_4);
            }
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 5) {
         if (FX_REC_VARIANT_TAG(t1_2) == 7) {
            _fx_N10Ast__typ_t result_6 = 0;
            fx_exn_t v_1 = {0};
            int_ b_4 = t1_2->u.TypUInt;
            if (is_shift_0) {
               FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(b_4, &result_6), _fx_catch_6);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_6, &result_0);
               FX_BREAK(_fx_catch_6);
            }
            else if (b_4 <= safe_max_ubits_0) {
               _fx_free_N10Ast__typ_t(&result_0); FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0); FX_BREAK(_fx_catch_6);
            }
            else {
               fx_str_t slit_1 =
                  FX_MAKE_STR("implicit type coercion for (int, uint32/uint64) pair is not allowed; use explicit type cast");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_1, &v_1, 0), _fx_catch_6);
               FX_THROW(&v_1, false, _fx_catch_6);
            }

         _fx_catch_6: ;
            fx_free_exn(&v_1);
            if (result_6) {
               _fx_free_N10Ast__typ_t(&result_6);
            }
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 6) {
         if (t1_2->u.TypSInt == 64) {
            if (FX_REC_VARIANT_TAG(t2_2) == 7) {
               if (t2_2->u.TypUInt <= 32) {
                  _fx_N10Ast__typ_t result_7 = 0;
                  FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(64, &result_7), _fx_catch_7);
                  _fx_free_N10Ast__typ_t(&result_0);
                  FX_COPY_PTR(result_7, &result_0);
                  FX_BREAK(_fx_catch_7);

               _fx_catch_7: ;
                  if (result_7) {
                     _fx_free_N10Ast__typ_t(&result_7);
                  }
                  goto _fx_endmatch_0;
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 6) {
         if (t2_2->u.TypSInt == 64) {
            if (FX_REC_VARIANT_TAG(t1_2) == 7) {
               if (t1_2->u.TypUInt <= 32) {
                  _fx_N10Ast__typ_t result_8 = 0;
                  FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(64, &result_8), _fx_catch_8);
                  _fx_free_N10Ast__typ_t(&result_0);
                  FX_COPY_PTR(result_8, &result_0);
                  FX_BREAK(_fx_catch_8);

               _fx_catch_8: ;
                  if (result_8) {
                     _fx_free_N10Ast__typ_t(&result_8);
                  }
                  goto _fx_endmatch_0;
               }
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 7) {
         if (FX_REC_VARIANT_TAG(t1_2) == 6) {
            fx_exn_t v_2 = {0};
            bool t_0;
            if (t1_2->u.TypSInt <= 32) {
               t_0 = t2_2->u.TypUInt <= safe_max_ubits_0;
            }
            else {
               t_0 = false;
            }
            if (t_0) {
               _fx_free_N10Ast__typ_t(&result_0); FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0); FX_BREAK(_fx_catch_9);
            }
            else {
               fx_str_t slit_2 =
                  FX_MAKE_STR(
                     "implicit type coercion for this (signed, unsigned) pair of integer is not allowed; use explicit type cast");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_2, &v_2, 0), _fx_catch_9);
               FX_THROW(&v_2, false, _fx_catch_9);
            }

         _fx_catch_9: ;
            fx_free_exn(&v_2);
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 6) {
         if (FX_REC_VARIANT_TAG(t1_2) == 7) {
            fx_exn_t v_3 = {0};
            bool t_1;
            if (t1_2->u.TypUInt <= safe_max_ubits_0) {
               t_1 = t2_2->u.TypSInt <= 32;
            }
            else {
               t_1 = false;
            }
            if (t_1) {
               _fx_free_N10Ast__typ_t(&result_0); FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0); FX_BREAK(_fx_catch_10);
            }
            else {
               fx_str_t slit_3 =
                  FX_MAKE_STR(
                     "implicit type coercion for this (unsigned, signed) pair of integer is not allowed; use explicit type cast");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_3, &v_3, 0), _fx_catch_10);
               FX_THROW(&v_3, false, _fx_catch_10);
            }

         _fx_catch_10: ;
            fx_free_exn(&v_3);
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 9) {
         if (FX_REC_VARIANT_TAG(t1_2) == 9) {
            if (allow_fp_0) {
               _fx_N10Ast__typ_t result_9 = 0;
               int_ max_b_0 = fx_maxi(fx_maxi(t1_2->u.TypFloat, t2_2->u.TypFloat), 32);
               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(max_b_0, &result_9), _fx_catch_11);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_9, &result_0);
               FX_BREAK(_fx_catch_11);

            _fx_catch_11: ;
               if (result_9) {
                  _fx_free_N10Ast__typ_t(&result_9);
               }
               goto _fx_endmatch_0;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 5) {
         if (FX_REC_VARIANT_TAG(t1_2) == 9) {
            if (allow_fp_0) {
               _fx_N10Ast__typ_t result_10 = 0;
               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(fx_maxi(t1_2->u.TypFloat, 32), &result_10), _fx_catch_12);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_10, &result_0);
               FX_BREAK(_fx_catch_12);

            _fx_catch_12: ;
               if (result_10) {
                  _fx_free_N10Ast__typ_t(&result_10);
               }
               goto _fx_endmatch_0;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 6) {
         if (FX_REC_VARIANT_TAG(t1_2) == 9) {
            if (allow_fp_0) {
               _fx_N10Ast__typ_t result_11 = 0;
               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(fx_maxi(t1_2->u.TypFloat, 32), &result_11), _fx_catch_13);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_11, &result_0);
               FX_BREAK(_fx_catch_13);

            _fx_catch_13: ;
               if (result_11) {
                  _fx_free_N10Ast__typ_t(&result_11);
               }
               goto _fx_endmatch_0;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 7) {
         if (FX_REC_VARIANT_TAG(t1_2) == 9) {
            if (allow_fp_0) {
               _fx_N10Ast__typ_t result_12 = 0;
               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(fx_maxi(t1_2->u.TypFloat, 32), &result_12), _fx_catch_14);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_12, &result_0);
               FX_BREAK(_fx_catch_14);

            _fx_catch_14: ;
               if (result_12) {
                  _fx_free_N10Ast__typ_t(&result_12);
               }
               goto _fx_endmatch_0;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 5) {
         if (FX_REC_VARIANT_TAG(t2_2) == 9) {
            if (allow_fp_0) {
               _fx_N10Ast__typ_t result_13 = 0;
               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(fx_maxi(t2_2->u.TypFloat, 32), &result_13), _fx_catch_15);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_13, &result_0);
               FX_BREAK(_fx_catch_15);

            _fx_catch_15: ;
               if (result_13) {
                  _fx_free_N10Ast__typ_t(&result_13);
               }
               goto _fx_endmatch_0;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 6) {
         if (FX_REC_VARIANT_TAG(t2_2) == 9) {
            if (allow_fp_0) {
               _fx_N10Ast__typ_t result_14 = 0;
               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(fx_maxi(t2_2->u.TypFloat, 32), &result_14), _fx_catch_16);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_14, &result_0);
               FX_BREAK(_fx_catch_16);

            _fx_catch_16: ;
               if (result_14) {
                  _fx_free_N10Ast__typ_t(&result_14);
               }
               goto _fx_endmatch_0;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 7) {
         if (FX_REC_VARIANT_TAG(t2_2) == 9) {
            if (allow_fp_0) {
               _fx_N10Ast__typ_t result_15 = 0;
               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(fx_maxi(t2_2->u.TypFloat, 32), &result_15), _fx_catch_17);
               _fx_free_N10Ast__typ_t(&result_0);
               FX_COPY_PTR(result_15, &result_0);
               FX_BREAK(_fx_catch_17);

            _fx_catch_17: ;
               if (result_15) {
                  _fx_free_N10Ast__typ_t(&result_15);
               }
               goto _fx_endmatch_0;
            }
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 12) {
         if (FX_REC_VARIANT_TAG(t2_2) == 12) {
            _fx_free_N10Ast__typ_t(&result_0);
            FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &result_0);
            FX_BREAK(_fx_catch_18);

         _fx_catch_18: ;
            goto _fx_endmatch_0;
         }
      }
      if (FX_REC_VARIANT_TAG(t1_2) == 12) {
         _fx_free_N10Ast__typ_t(&t1_1);
         FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &t1_1);
         _fx_free_N10Ast__typ_t(&t2_1);
         FX_COPY_PTR(t2_2, &t2_1);
         goto _fx_endmatch_0;
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 12) {
         _fx_free_N10Ast__typ_t(&t1_1);
         FX_COPY_PTR(t1_2, &t1_1);
         _fx_free_N10Ast__typ_t(&t2_1);
         FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &t2_1);
         goto _fx_endmatch_0;
      }
      if (FX_REC_VARIANT_TAG(t2_2) == 17) {
         if (FX_REC_VARIANT_TAG(t1_2) == 17) {
            fx_exn_t v_4 = {0};
            _fx_LN10Ast__typ_t v_5 = 0;
            _fx_LN10Ast__typ_t tl1_0 = 0;
            _fx_LN10Ast__typ_t tl2_0 = 0;
            _fx_N10Ast__typ_t result_16 = 0;
            fx_exn_t v_6 = {0};
            _fx_LN10Ast__typ_t tl1_1 = t1_2->u.TypTuple;
            _fx_LN10Ast__typ_t tl2_1 = t2_2->u.TypTuple;
            if (!allow_tuples_0) {
               fx_str_t slit_4 = FX_MAKE_STR("tuples are not allowed in this operation");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_4, &v_4, 0), _fx_catch_20);
               FX_THROW(&v_4, false, _fx_catch_20);
            }
            else {
               int_ v_7 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(tl1_1, 0);
               int_ v_8 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(tl2_1, 0);
               if (v_7 == v_8) {
                  _fx_LN10Ast__typ_t lstend_0 = 0;
                  FX_COPY_PTR(tl1_1, &tl1_0);
                  _fx_LN10Ast__typ_t lst_0 = tl1_0;
                  FX_COPY_PTR(tl2_1, &tl2_0);
                  _fx_LN10Ast__typ_t lst_1 = tl2_0;
                  for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl) {
                     _fx_N10Ast__typ_t res_0 = 0;
                     _fx_N10Ast__typ_t et2_0 = lst_1->hd;
                     _fx_N10Ast__typ_t et1_0 = lst_0->hd;
                     FX_CALL(
                        _fx_M13Ast_typecheckFM13coerce_types_N10Ast__typ_t7N10Ast__typ_tN10Ast__typ_tBBBR10Ast__loc_ti(et1_0,
                           et2_0, allow_fp_0, allow_tuples_0, is_shift_0, loc_0, safe_max_ubits_0, &res_0, 0), _fx_catch_19);
                     _fx_LN10Ast__typ_t node_0 = 0;
                     FX_CALL(_fx_cons_LN10Ast__typ_t(res_0, 0, false, &node_0), _fx_catch_19);
                     FX_LIST_APPEND(v_5, lstend_0, node_0);

                  _fx_catch_19: ;
                     if (res_0) {
                        _fx_free_N10Ast__typ_t(&res_0);
                     }
                     FX_CHECK_EXN(_fx_catch_20);
                  }
                  int s_0 = !lst_0 + !lst_1;
                  FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_20);
                  FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(v_5, &result_16), _fx_catch_20);
                  _fx_free_N10Ast__typ_t(&result_0);
                  FX_COPY_PTR(result_16, &result_0);
                  FX_BREAK(_fx_catch_20);
               }
               else {
                  fx_str_t slit_5 = FX_MAKE_STR("tuples have different number of elements");
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_5, &v_6, 0), _fx_catch_20);
                  FX_THROW(&v_6, false, _fx_catch_20);
               }
            }

         _fx_catch_20: ;
            fx_free_exn(&v_6);
            if (result_16) {
               _fx_free_N10Ast__typ_t(&result_16);
            }
            if (tl2_0) {
               _fx_free_LN10Ast__typ_t(&tl2_0);
            }
            if (tl1_0) {
               _fx_free_LN10Ast__typ_t(&tl1_0);
            }
            if (v_5) {
               _fx_free_LN10Ast__typ_t(&v_5);
            }
            fx_free_exn(&v_4);
            goto _fx_endmatch_0;
         }
      }
      fx_exn_t v_9 = {0};
      fx_str_t slit_6 = FX_MAKE_STR("the types cannot be implicitly coerced; use explicit type cast");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_6, &v_9, 0), _fx_catch_21);
      FX_THROW(&v_9, false, _fx_catch_21);

   _fx_catch_21: ;
      fx_free_exn(&v_9);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_22);

   _fx_catch_22: ;
      if (t2_2) {
         _fx_free_N10Ast__typ_t(&t2_2);
      }
      if (t1_2) {
         _fx_free_N10Ast__typ_t(&t1_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(result_0, fx_result);

_fx_cleanup: ;
   if (result_0) {
      _fx_free_N10Ast__typ_t(&result_0);
   }
   if (t1_1) {
      _fx_free_N10Ast__typ_t(&t1_1);
   }
   if (t2_1) {
      _fx_free_N10Ast__typ_t(&t2_1);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN16Ast__env_entry_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_1 = {0};
   _fx_Nt6option1LN16Ast__env_entry_t result_0 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t t_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t cmp_0 = {0};
   _fx_Nt6option1LN16Ast__env_entry_t v_2 = {0};
   int fx_status = 0;
   FX_COPY_PTR(env_0->root, &v_0);
   FX_COPY_FP(&env_0->cmp, &v_1);
   FX_COPY_PTR(v_0, &t_0);
   _fx_R9Ast__id_t xk_0 = *n_0;
   FX_COPY_FP(&v_1, &cmp_0);
   for (;;) {
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t t_1 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t cmp_1 = {0};
      FX_COPY_PTR(t_0, &t_1);
      _fx_R9Ast__id_t xk_1 = xk_0;
      FX_COPY_FP(&cmp_0, &cmp_1);
      if ((t_1 != 0) + 1 == 2) {
         _fx_Nt6option1LN16Ast__env_entry_t result_1 = {0};
         _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
            vcase_0 = &t_1->u.Node;
         int_ c_0;
         FX_CALL(cmp_1.fp(&xk_1, &vcase_0->t2, &c_0, cmp_1.fcv), _fx_catch_0);
         if (c_0 < 0) {
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t* l_0 = &vcase_0->t1;
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_0);
            FX_COPY_PTR(*l_0, &t_0);
            xk_0 = xk_1;
            FX_FREE_FP(&cmp_0);
            FX_COPY_FP(&cmp_1, &cmp_0);
         }
         else if (c_0 > 0) {
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t* r_0 = &vcase_0->t4;
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_0);
            FX_COPY_PTR(*r_0, &t_0);
            xk_0 = xk_1;
            FX_FREE_FP(&cmp_0);
            FX_COPY_FP(&cmp_1, &cmp_0);
         }
         else {
            _fx_M13Ast_typecheckFM4SomeNt6option1LN16Ast__env_entry_t1LN16Ast__env_entry_t(vcase_0->t3, &result_1);
            _fx_free_Nt6option1LN16Ast__env_entry_t(&result_0);
            _fx_copy_Nt6option1LN16Ast__env_entry_t(&result_1, &result_0);
            FX_BREAK(_fx_catch_0);
         }

      _fx_catch_0: ;
         _fx_free_Nt6option1LN16Ast__env_entry_t(&result_1);
      }
      else {
         _fx_free_Nt6option1LN16Ast__env_entry_t(&result_0);
         _fx_copy_Nt6option1LN16Ast__env_entry_t(&_fx_g21Ast_typecheck__None4_, &result_0);
         FX_BREAK(_fx_catch_1);

      _fx_catch_1: ;
      }
      FX_CHECK_EXN(_fx_catch_2);

   _fx_catch_2: ;
      FX_FREE_FP(&cmp_1);
      if (t_1) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_1);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Nt6option1LN16Ast__env_entry_t(&result_0, &v_2);
   if (v_2.tag == 2) {
      FX_COPY_PTR(v_2.u.Some, fx_result);
   }

_fx_cleanup: ;
   if (v_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
   }
   FX_FREE_FP(&v_1);
   _fx_free_Nt6option1LN16Ast__env_entry_t(&result_0);
   if (t_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_0);
   }
   FX_FREE_FP(&cmp_0);
   _fx_free_Nt6option1LN16Ast__env_entry_t(&v_2);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM14add_typ_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* key_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_LN16Ast__env_entry_t entries_0 = 0;
   _fx_N16Ast__env_entry_t v_0 = 0;
   _fx_LN16Ast__env_entry_t v_1 = 0;
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_2 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_3 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_4 = 0;
   _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_5 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_6 = {0};
   int fx_status = 0;
   FX_CALL(
      _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(key_0, env_0,
         &entries_0, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM6EnvTypN16Ast__env_entry_t1N10Ast__typ_t(t_0, &v_0), _fx_cleanup);
   FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_0, entries_0, true, &v_1), _fx_cleanup);
   FX_COPY_PTR(env_0->root, &v_2);
   FX_COPY_FP(&env_0->cmp, &v_3);
   FX_CALL(
      _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
         v_2, key_0, v_1, &v_3, &v_4, 0), _fx_cleanup);
   if ((v_4 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_0 = &v_4->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_7 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
               &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_7), _fx_catch_0);
         _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_7, false, &v_5);

      _fx_catch_0: ;
         if (v_7) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_7);
         }
         goto _fx_endmatch_0;
      }
   }
   _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_4, true, &v_5);

_fx_endmatch_0: ;
   FX_CHECK_EXN(_fx_cleanup);
   FX_COPY_PTR(v_5.t0, &new_root_0);
   FX_COPY_FP(&env_0->cmp, &v_6);
   _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_6, fx_result);

_fx_cleanup: ;
   if (entries_0) {
      _fx_free_LN16Ast__env_entry_t(&entries_0);
   }
   if (v_0) {
      _fx_free_N16Ast__env_entry_t(&v_0);
   }
   if (v_1) {
      _fx_free_LN16Ast__env_entry_t(&v_1);
   }
   if (v_2) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
   }
   FX_FREE_FP(&v_3);
   if (v_4) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
   }
   _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_5);
   if (new_root_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
   }
   FX_FREE_FP(&v_6);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* key_0,
   struct _fx_R9Ast__id_t* i_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_LN16Ast__env_entry_t entries_0 = 0;
   _fx_LN16Ast__env_entry_t entries_1 = 0;
   _fx_N16Ast__env_entry_t v_0 = 0;
   _fx_LN16Ast__env_entry_t v_1 = 0;
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_2 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_3 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_4 = 0;
   _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_5 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_6 = {0};
   int fx_status = 0;
   FX_CALL(
      _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(key_0, env_0,
         &entries_0, 0), _fx_cleanup);
   bool __fold_result___0 = false;
   _fx_LN16Ast__env_entry_t lst_0 = entries_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N16Ast__env_entry_t e_0 = lst_0->hd;
      bool res_0;
      if (FX_REC_VARIANT_TAG(e_0) == 1) {
         bool res_1;
         FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&e_0->u.EnvId, i_0, &res_1, 0), _fx_catch_0);
         if (res_1) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      res_0 = false;

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_0);
      if (res_0) {
         __fold_result___0 = true; FX_BREAK(_fx_catch_0);
      }

   _fx_catch_0: ;
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   if (!__fold_result___0) {
      FX_COPY_PTR(entries_0, &entries_1);
   }
   else {
      _fx_LN16Ast__env_entry_t lstend_0 = 0;
      _fx_LN16Ast__env_entry_t lst_1 = entries_0;
      for (; lst_1; lst_1 = lst_1->tl) {
         _fx_N16Ast__env_entry_t x_0 = lst_1->hd;
         bool res_2;
         if (FX_REC_VARIANT_TAG(x_0) == 1) {
            bool res_3;
            FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&x_0->u.EnvId, i_0, &res_3, 0), _fx_catch_1);
            if (res_3) {
               res_2 = false; goto _fx_endmatch_1;
            }
         }
         res_2 = true;

      _fx_endmatch_1: ;
         FX_CHECK_EXN(_fx_catch_1);
         if (!res_2) {
            FX_CONTINUE(_fx_catch_1);
         }
         _fx_LN16Ast__env_entry_t node_0 = 0;
         FX_CALL(_fx_cons_LN16Ast__env_entry_t(x_0, 0, false, &node_0), _fx_catch_1);
         FX_LIST_APPEND(entries_1, lstend_0, node_0);

      _fx_catch_1: ;
         FX_CHECK_CONTINUE();
         FX_CHECK_EXN(_fx_cleanup);
      }
   }
   FX_CALL(_fx_M3AstFM5EnvIdN16Ast__env_entry_t1RM4id_t(i_0, &v_0), _fx_cleanup);
   FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_0, entries_1, true, &v_1), _fx_cleanup);
   FX_COPY_PTR(env_0->root, &v_2);
   FX_COPY_FP(&env_0->cmp, &v_3);
   FX_CALL(
      _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
         v_2, key_0, v_1, &v_3, &v_4, 0), _fx_cleanup);
   if ((v_4 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_0 = &v_4->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_7 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
               &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_7), _fx_catch_2);
         _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_7, false, &v_5);

      _fx_catch_2: ;
         if (v_7) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_7);
         }
         goto _fx_endmatch_2;
      }
   }
   _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_4, true, &v_5);

_fx_endmatch_2: ;
   FX_CHECK_EXN(_fx_cleanup);
   FX_COPY_PTR(v_5.t0, &new_root_0);
   FX_COPY_FP(&env_0->cmp, &v_6);
   _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_6, fx_result);

_fx_cleanup: ;
   if (entries_0) {
      _fx_free_LN16Ast__env_entry_t(&entries_0);
   }
   if (entries_1) {
      _fx_free_LN16Ast__env_entry_t(&entries_1);
   }
   if (v_0) {
      _fx_free_N16Ast__env_entry_t(&v_0);
   }
   if (v_1) {
      _fx_free_LN16Ast__env_entry_t(&v_1);
   }
   if (v_2) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
   }
   FX_FREE_FP(&v_3);
   if (v_4) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
   }
   _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_5);
   if (new_root_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
   }
   FX_FREE_FP(&v_6);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
   struct _fx_R9Ast__id_t* key_0,
   struct _fx_R9Ast__id_t* i_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_FPv1N14Ast__id_info_t* check_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_LN16Ast__env_entry_t entries_0 = 0;
   _fx_LN16Ast__env_entry_t entries_1 = 0;
   _fx_N16Ast__env_entry_t v_0 = 0;
   _fx_LN16Ast__env_entry_t v_1 = 0;
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_2 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_3 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_4 = 0;
   _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_5 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_6 = {0};
   int fx_status = 0;
   FX_CALL(
      _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(key_0, env_0,
         &entries_0, 0), _fx_cleanup);
   _fx_LN16Ast__env_entry_t lstend_0 = 0;
   _fx_LN16Ast__env_entry_t lst_0 = entries_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N16Ast__env_entry_t e_0 = lst_0->hd;
      if (FX_REC_VARIANT_TAG(e_0) == 1) {
         _fx_N14Ast__id_info_t v_7 = {0};
         _fx_R9Ast__id_t* j_0 = &e_0->u.EnvId;
         bool res_0;
         FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(i_0, j_0, &res_0, 0), _fx_catch_0);
         if (res_0) {
            FX_CONTINUE(_fx_catch_0);
         }
         FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(j_0, &_fx_g10Ast__noloc, &v_7, 0), _fx_catch_0);
         FX_CALL(check_0->fp(&v_7, check_0->fcv), _fx_catch_0);

      _fx_catch_0: ;
         _fx_free_N14Ast__id_info_t(&v_7);
      }
      FX_CHECK_EXN(_fx_catch_1);
      _fx_LN16Ast__env_entry_t node_0 = 0;
      FX_CALL(_fx_cons_LN16Ast__env_entry_t(e_0, 0, false, &node_0), _fx_catch_1);
      FX_LIST_APPEND(entries_1, lstend_0, node_0);

   _fx_catch_1: ;
      FX_CHECK_CONTINUE();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_CALL(_fx_M3AstFM5EnvIdN16Ast__env_entry_t1RM4id_t(i_0, &v_0), _fx_cleanup);
   FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_0, entries_1, true, &v_1), _fx_cleanup);
   FX_COPY_PTR(env_0->root, &v_2);
   FX_COPY_FP(&env_0->cmp, &v_3);
   FX_CALL(
      _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
         v_2, key_0, v_1, &v_3, &v_4, 0), _fx_cleanup);
   if ((v_4 != 0) + 1 == 2) {
      _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
         vcase_0 = &v_4->u.Node;
      if (vcase_0->t0.tag == 1) {
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_8 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
               &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_8), _fx_catch_2);
         _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_8, false, &v_5);

      _fx_catch_2: ;
         if (v_8) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_8);
         }
         goto _fx_endmatch_0;
      }
   }
   _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_4, true, &v_5);

_fx_endmatch_0: ;
   FX_CHECK_EXN(_fx_cleanup);
   FX_COPY_PTR(v_5.t0, &new_root_0);
   FX_COPY_FP(&env_0->cmp, &v_6);
   _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_6, fx_result);

_fx_cleanup: ;
   if (entries_0) {
      _fx_free_LN16Ast__env_entry_t(&entries_0);
   }
   if (entries_1) {
      _fx_free_LN16Ast__env_entry_t(&entries_1);
   }
   if (v_0) {
      _fx_free_N16Ast__env_entry_t(&v_0);
   }
   if (v_1) {
      _fx_free_LN16Ast__env_entry_t(&v_1);
   }
   if (v_2) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
   }
   FX_FREE_FP(&v_3);
   if (v_4) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
   }
   _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_5);
   if (new_root_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
   }
   FX_FREE_FP(&v_6);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM14inst_merge_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_from_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_to_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t
      __lambda___0 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_0 = 0;
   int fx_status = 0;
   _fx_M13Ast_typecheckFM7make_fpFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t1Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
      env_to_0, &__lambda___0);
   FX_COPY_PTR(env_from_0->root, &v_0);
   FX_CALL(
      _fx_M13Ast_typecheckFM7update_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
         v_0, &__lambda___0, env_to_0, fx_result, 0), _fx_cleanup);

_fx_cleanup: ;
   FX_FREE_FP(&__lambda___0);
   if (v_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
   }
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* i_0,
   struct _fx_LN16Ast__env_entry_t_data_t* entries_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* new_env_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_1 = {0};
   _fx_Nt6option1LN16Ast__env_entry_t result_0 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t t_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t cmp_0 = {0};
   _fx_Nt6option1LN16Ast__env_entry_t v_2 = {0};
   int fx_status = 0;
   _fx_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t*
      cv_0 =
      (_fx_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t*)
         fx_fv;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_to_0 = &cv_0->t0;
   FX_COPY_PTR(env_to_0->root, &v_0);
   FX_COPY_FP(&env_to_0->cmp, &v_1);
   FX_COPY_PTR(v_0, &t_0);
   _fx_R9Ast__id_t xk_0 = *i_0;
   FX_COPY_FP(&v_1, &cmp_0);
   for (;;) {
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t t_1 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t cmp_1 = {0};
      FX_COPY_PTR(t_0, &t_1);
      _fx_R9Ast__id_t xk_1 = xk_0;
      FX_COPY_FP(&cmp_0, &cmp_1);
      if ((t_1 != 0) + 1 == 2) {
         _fx_Nt6option1LN16Ast__env_entry_t result_1 = {0};
         _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
            vcase_0 = &t_1->u.Node;
         int_ c_0;
         FX_CALL(cmp_1.fp(&xk_1, &vcase_0->t2, &c_0, cmp_1.fcv), _fx_catch_0);
         if (c_0 < 0) {
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t* l_0 = &vcase_0->t1;
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_0);
            FX_COPY_PTR(*l_0, &t_0);
            xk_0 = xk_1;
            FX_FREE_FP(&cmp_0);
            FX_COPY_FP(&cmp_1, &cmp_0);
         }
         else if (c_0 > 0) {
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t* r_0 = &vcase_0->t4;
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_0);
            FX_COPY_PTR(*r_0, &t_0);
            xk_0 = xk_1;
            FX_FREE_FP(&cmp_0);
            FX_COPY_FP(&cmp_1, &cmp_0);
         }
         else {
            _fx_M13Ast_typecheckFM4SomeNt6option1LN16Ast__env_entry_t1LN16Ast__env_entry_t(vcase_0->t3, &result_1);
            _fx_free_Nt6option1LN16Ast__env_entry_t(&result_0);
            _fx_copy_Nt6option1LN16Ast__env_entry_t(&result_1, &result_0);
            FX_BREAK(_fx_catch_0);
         }

      _fx_catch_0: ;
         _fx_free_Nt6option1LN16Ast__env_entry_t(&result_1);
      }
      else {
         _fx_free_Nt6option1LN16Ast__env_entry_t(&result_0);
         _fx_copy_Nt6option1LN16Ast__env_entry_t(&_fx_g21Ast_typecheck__None4_, &result_0);
         FX_BREAK(_fx_catch_1);

      _fx_catch_1: ;
      }
      FX_CHECK_EXN(_fx_catch_2);

   _fx_catch_2: ;
      FX_FREE_FP(&cmp_1);
      if (t_1) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_1);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Nt6option1LN16Ast__env_entry_t(&result_0, &v_2);
   if (v_2.tag == 2) {
      _fx_LN16Ast__env_entry_t __fold_result___0 = 0;
      _fx_LN16Ast__env_entry_t extra_entries_0 = 0;
      _fx_LN16Ast__env_entry_t __fold_result___1 = 0;
      _fx_LN16Ast__env_entry_t v_3 = 0;
      _fx_LN16Ast__env_entry_t new_entries_0 = 0;
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_4 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t v_5 = {0};
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_6 = 0;
      _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_7 = {0};
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t v_8 = {0};
      _fx_LN16Ast__env_entry_t prev_entries_0 = v_2.u.Some;
      _fx_LN16Ast__env_entry_t lst_0 = entries_0;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_LN16Ast__env_entry_t extra_entries_1 = 0;
         _fx_LN16Ast__env_entry_t v_9 = 0;
         _fx_N16Ast__env_entry_t e_0 = lst_0->hd;
         FX_COPY_PTR(__fold_result___0, &extra_entries_1);
         if (FX_REC_VARIANT_TAG(e_0) == 1) {
            _fx_N14Ast__id_info_t v_10 = {0};
            _fx_LN16Ast__env_entry_t prev_entries_1 = 0;
            FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&e_0->u.EnvId, &_fx_g10Ast__noloc, &v_10, 0),
               _fx_catch_4);
            bool add_0;
            if (v_10.tag == 3) {
               add_0 = true;
            }
            else {
               add_0 = false;
            }
            FX_CHECK_EXN(_fx_catch_4);
            bool v_11;
            if (add_0) {
               bool __fold_result___2 = false;
               FX_COPY_PTR(prev_entries_0, &prev_entries_1);
               _fx_LN16Ast__env_entry_t lst_1 = prev_entries_1;
               for (; lst_1; lst_1 = lst_1->tl) {
                  _fx_N16Ast__env_entry_t b_0 = lst_1->hd;
                  bool v_12;
                  FX_CALL(_fx_M13Ast_typecheckFM15__eq_variants__B2N16Ast__env_entry_tN16Ast__env_entry_t(e_0, b_0, &v_12, 0),
                     _fx_catch_3);
                  if (v_12) {
                     __fold_result___2 = true; FX_BREAK(_fx_catch_3);
                  }

               _fx_catch_3: ;
                  FX_CHECK_BREAK();
                  FX_CHECK_EXN(_fx_catch_4);
               }
               v_11 = !__fold_result___2;
            }
            else {
               v_11 = false;
            }
            if (v_11) {
               FX_CALL(_fx_cons_LN16Ast__env_entry_t(e_0, extra_entries_1, true, &v_9), _fx_catch_4);
            }
            else {
               FX_COPY_PTR(extra_entries_1, &v_9);
            }

         _fx_catch_4: ;
            if (prev_entries_1) {
               _fx_free_LN16Ast__env_entry_t(&prev_entries_1);
            }
            _fx_free_N14Ast__id_info_t(&v_10);
         }
         else {
            FX_COPY_PTR(extra_entries_1, &v_9);
         }
         FX_CHECK_EXN(_fx_catch_5);
         _fx_free_LN16Ast__env_entry_t(&__fold_result___0);
         FX_COPY_PTR(v_9, &__fold_result___0);

      _fx_catch_5: ;
         if (v_9) {
            _fx_free_LN16Ast__env_entry_t(&v_9);
         }
         if (extra_entries_1) {
            _fx_free_LN16Ast__env_entry_t(&extra_entries_1);
         }
         FX_CHECK_EXN(_fx_catch_10);
      }
      FX_COPY_PTR(__fold_result___0, &extra_entries_0);
      if (extra_entries_0 == 0) {
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_env_0, fx_result);
      }
      else {
         _fx_LN16Ast__env_entry_t lst_2 = extra_entries_0;
         for (; lst_2; lst_2 = lst_2->tl) {
            _fx_LN16Ast__env_entry_t r_1 = 0;
            _fx_N16Ast__env_entry_t a_0 = lst_2->hd;
            FX_COPY_PTR(__fold_result___1, &r_1);
            FX_CALL(_fx_cons_LN16Ast__env_entry_t(a_0, r_1, false, &r_1), _fx_catch_6);
            _fx_free_LN16Ast__env_entry_t(&__fold_result___1);
            FX_COPY_PTR(r_1, &__fold_result___1);

         _fx_catch_6: ;
            if (r_1) {
               _fx_free_LN16Ast__env_entry_t(&r_1);
            }
            FX_CHECK_EXN(_fx_catch_10);
         }
         FX_COPY_PTR(__fold_result___1, &v_3);
         if (v_3 == 0) {
            FX_COPY_PTR(prev_entries_0, &new_entries_0);
         }
         else if (prev_entries_0 == 0) {
            FX_COPY_PTR(v_3, &new_entries_0);
         }
         else {
            _fx_LN16Ast__env_entry_t v_13 = 0;
            _fx_LN16Ast__env_entry_t lstend_0 = 0;
            _fx_LN16Ast__env_entry_t lst_3 = v_3;
            for (; lst_3; lst_3 = lst_3->tl) {
               _fx_N16Ast__env_entry_t x_0 = lst_3->hd;
               _fx_LN16Ast__env_entry_t node_0 = 0;
               FX_CALL(_fx_cons_LN16Ast__env_entry_t(x_0, 0, false, &node_0), _fx_catch_7);
               FX_LIST_APPEND(v_13, lstend_0, node_0);

            _fx_catch_7: ;
               FX_CHECK_EXN(_fx_catch_8);
            }
            _fx_M13Ast_typecheckFM5link2LN16Ast__env_entry_t2LN16Ast__env_entry_tLN16Ast__env_entry_t(v_13, prev_entries_0,
               &new_entries_0, 0);

         _fx_catch_8: ;
            if (v_13) {
               _fx_free_LN16Ast__env_entry_t(&v_13);
            }
         }
         FX_CHECK_EXN(_fx_catch_10);
         FX_COPY_PTR(new_env_0->root, &v_4);
         FX_COPY_FP(&new_env_0->cmp, &v_5);
         FX_CALL(
            _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
               v_4, i_0, new_entries_0, &v_5, &v_6, 0), _fx_catch_10);
         if ((v_6 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
               vcase_1 = &v_6->u.Node;
            if (vcase_1->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_14 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, vcase_1->t1, &vcase_1->t2, vcase_1->t3, vcase_1->t4, &v_14), _fx_catch_9);
               _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_14, false, &v_7);

            _fx_catch_9: ;
               if (v_14) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_14);
               }
               goto _fx_endmatch_0;
            }
         }
         _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_6, true, &v_7);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_10);
         FX_COPY_PTR(v_7.t0, &new_root_0);
         FX_COPY_FP(&new_env_0->cmp, &v_8);
         _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_8, fx_result);
      }

   _fx_catch_10: ;
      FX_FREE_FP(&v_8);
      if (new_root_0) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
      }
      _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_7);
      if (v_6) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_6);
      }
      FX_FREE_FP(&v_5);
      if (v_4) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
      }
      if (new_entries_0) {
         _fx_free_LN16Ast__env_entry_t(&new_entries_0);
      }
      if (v_3) {
         _fx_free_LN16Ast__env_entry_t(&v_3);
      }
      if (__fold_result___1) {
         _fx_free_LN16Ast__env_entry_t(&__fold_result___1);
      }
      if (extra_entries_0) {
         _fx_free_LN16Ast__env_entry_t(&extra_entries_0);
      }
      if (__fold_result___0) {
         _fx_free_LN16Ast__env_entry_t(&__fold_result___0);
      }
   }
   else {
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_env_0, fx_result);
   }

_fx_cleanup: ;
   if (v_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
   }
   FX_FREE_FP(&v_1);
   _fx_free_Nt6option1LN16Ast__env_entry_t(&result_0);
   if (t_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&t_0);
   }
   FX_FREE_FP(&cmp_0);
   _fx_free_Nt6option1LN16Ast__env_entry_t(&v_2);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t1Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg0,
   struct _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t*
      fx_result)
{
   FX_MAKE_FP_IMPL_START(
      _fx_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t,
      _fx_free_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t,
      _fx_M13Ast_typecheckFM10__lambda__Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(arg0, &fcv->t0);
   return 0;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM23check_for_duplicate_typFPv1N14Ast__id_info_t3R9Ast__id_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* key_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_FPv1N14Ast__id_info_t* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t3R9Ast__id_tR10Ast__loc_tLN12Ast__scope_t(key_0, loc_0, sc_0, fx_result);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t(struct _fx_N14Ast__id_info_t* i_0, void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t_cldata_t*)fx_fv;
   _fx_LN12Ast__scope_t sc_0 = cv_0->t2;
   int tag_0 = i_0->tag;
   bool res_0;
   if (tag_0 == 5) {
      res_0 = true;
   }
   else if (tag_0 == 6) {
      res_0 = true;
   }
   else if (tag_0 == 7) {
      res_0 = true;
   }
   else {
      res_0 = false;
   }
   FX_CHECK_EXN(_fx_cleanup);
   if (res_0) {
      _fx_LN12Ast__scope_t v_0 = 0;
      fx_str_t v_1 = {0};
      fx_str_t v_2 = {0};
      fx_str_t v_3 = {0};
      fx_exn_t v_4 = {0};
      FX_CALL(_fx_M3AstFM9get_scopeLN12Ast__scope_t1N14Ast__id_info_t(i_0, &v_0, 0), _fx_catch_0);
      _fx_N12Ast__scope_t v_5;
      if (v_0 != 0) {
         v_5 = v_0->hd;
      }
      else {
         FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_0);
      }
      FX_CHECK_EXN(_fx_catch_0);
      _fx_N12Ast__scope_t v_6;
      if (sc_0 != 0) {
         v_6 = sc_0->hd;
      }
      else {
         FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_0);
      }
      FX_CHECK_EXN(_fx_catch_0);
      bool res_1;
      FX_CALL(_fx_M13Ast_typecheckFM15__eq_variants__B2N12Ast__scope_tN12Ast__scope_t(&v_5, &v_6, &res_1, 0), _fx_catch_0);
      if (res_1) {
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&cv_0->t0, &v_1, 0), _fx_catch_0);
         _fx_R10Ast__loc_t v_7;
         FX_CALL(_fx_M3AstFM14get_idinfo_locRM5loc_t1N14Ast__id_info_t(i_0, &v_7, 0), _fx_catch_0);
         FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(&v_7, &v_2, 0), _fx_catch_0);
         fx_str_t slit_0 = FX_MAKE_STR("the type ");
         fx_str_t slit_1 = FX_MAKE_STR(" is re-declared in the same scope; the previous declaration is here ");
         {
            const fx_str_t strs_0[] = { slit_0, v_1, slit_1, v_2 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_0, 4, &v_3), _fx_catch_0);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&cv_0->t1, &v_3, &v_4, 0), _fx_catch_0);
         FX_THROW(&v_4, false, _fx_catch_0);
      }

   _fx_catch_0: ;
      fx_free_exn(&v_4);
      FX_FREE_STR(&v_3);
      FX_FREE_STR(&v_2);
      FX_FREE_STR(&v_1);
      FX_FREE_LIST_SIMPLE(&v_0);
      goto _fx_endmatch_0;
   }

_fx_endmatch_0: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t3R9Ast__id_tR10Ast__loc_tLN12Ast__scope_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_LN12Ast__scope_t_data_t* arg2,
   struct _fx_FPv1N14Ast__id_info_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t_cldata_t,
      _fx_free_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t, _fx_M13Ast_typecheckFM10__lambda__v1N14Ast__id_info_t);
   fcv->t0 = *arg0;
   fcv->t1 = *arg1;
   FX_COPY_PTR(arg2, &fcv->t2);
   return 0;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM30check_for_rec_field_duplicatesv2LR9Ast__id_tR10Ast__loc_t(
   struct _fx_LR9Ast__id_t_data_t* rfnames_0,
   struct _fx_R10Ast__loc_t* loc_0,
   void* fx_fv)
{
   _fx_LR9Ast__id_t rfnames_1 = 0;
   int fx_status = 0;
   int_ i_0 = 0;
   FX_COPY_PTR(rfnames_0, &rfnames_1);
   _fx_LR9Ast__id_t lst_0 = rfnames_1;
   for (; lst_0; lst_0 = lst_0->tl, i_0 += 1) {
      _fx_R9Ast__id_t* ni_0 = &lst_0->hd;
      int_ j_0 = 0;
      _fx_LR9Ast__id_t lst_1 = rfnames_0;
      for (; lst_1; lst_1 = lst_1->tl, j_0 += 1) {
         fx_str_t v_0 = {0};
         fx_str_t v_1 = {0};
         fx_exn_t v_2 = {0};
         _fx_R9Ast__id_t* nj_0 = &lst_1->hd;
         bool t_0;
         if (i_0 > j_0) {
            FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(ni_0, nj_0, &t_0, 0), _fx_catch_0);
         }
         else {
            t_0 = false;
         }
         if (t_0) {
            FX_CALL(_fx_M3AstFM6stringS1RM4id_t(ni_0, &v_0, 0), _fx_catch_0);
            fx_str_t slit_0 = FX_MAKE_STR("duplicate record field \'");
            fx_str_t slit_1 = FX_MAKE_STR("\'");
            {
               const fx_str_t strs_0[] = { slit_0, v_0, slit_1 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &v_1), _fx_catch_0);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_1, &v_2, 0), _fx_catch_0);
            FX_THROW(&v_2, false, _fx_catch_0);
         }

      _fx_catch_0: ;
         fx_free_exn(&v_2);
         FX_FREE_STR(&v_1);
         FX_FREE_STR(&v_0);
         FX_CHECK_EXN(_fx_catch_1);
      }

   _fx_catch_1: ;
      FX_CHECK_EXN(_fx_cleanup);
   }

_fx_cleanup: ;
   FX_FREE_LIST_SIMPLE(&rfnames_1);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM14typ_bounds_intTa2l1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Ta2l* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   int tag_0 = FX_REC_VARIANT_TAG(t_0);
   if (tag_0 == 6) {
      if (t_0->u.TypSInt == 8) {
         _fx_Ta2l tup_0 = { -128LL, 127LL }; *fx_result = tup_0; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 6) {
      if (t_0->u.TypSInt == 16) {
         _fx_Ta2l tup_1 = { -32768LL, 32767LL }; *fx_result = tup_1; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 6) {
      if (t_0->u.TypSInt == 32) {
         _fx_Ta2l tup_2 = { -2147483648LL, 2147483647LL }; *fx_result = tup_2; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 6) {
      if (t_0->u.TypSInt == 64) {
         _fx_Ta2l tup_3 = { -9223372036854775807LL, 9223372036854775807LL }; *fx_result = tup_3; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 7) {
      if (t_0->u.TypUInt == 8) {
         _fx_Ta2l tup_4 = { 0LL, 255LL }; *fx_result = tup_4; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 7) {
      if (t_0->u.TypUInt == 16) {
         _fx_Ta2l tup_5 = { 0LL, 65535LL }; *fx_result = tup_5; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 7) {
      if (t_0->u.TypUInt == 32) {
         _fx_Ta2l tup_6 = { 0LL, 4294967295LL }; *fx_result = tup_6; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 7) {
      if (t_0->u.TypUInt == 64) {
         _fx_Ta2l tup_7 = { 0LL, 9223372036854775807LL }; *fx_result = tup_7; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 8) {
      _fx_Ta2l tup_8 = { -9223372036854775807LL, 9223372036854775807LL }; *fx_result = tup_8; goto _fx_endmatch_0;
   }
   if (tag_0 == 9) {
      if (t_0->u.TypFloat == 16) {
         _fx_Ta2l tup_9 = { -4096LL, 4096LL }; *fx_result = tup_9; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 9) {
      if (t_0->u.TypFloat == 32) {
         _fx_Ta2l tup_10 = { -16777216LL, 16777216LL }; *fx_result = tup_10; goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 9) {
      if (t_0->u.TypFloat == 64) {
         _fx_Ta2l tup_11 = { -9007199254740992LL, 9007199254740992LL }; *fx_result = tup_11; goto _fx_endmatch_0;
      }
   }
   _fx_Ta2l tup_12 = { 0LL, -1LL };
   *fx_result = tup_12;

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM22try_unify_with_literalN10Ast__exp_t3N10Ast__typ_tN10Ast__exp_tS(
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__exp_t_data_t* e2_0,
   fx_str_t* msg_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t t1__0 = 0;
   _fx_T2N10Ast__typ_tR10Ast__loc_t v_0 = {0};
   _fx_N10Ast__typ_t t2_0 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t1_0, &t1__0, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e2_0, &v_0, 0), _fx_cleanup);
   FX_COPY_PTR(v_0.t0, &t2_0);
   _fx_R10Ast__loc_t eloc2_0 = v_0.t1;
   bool res_0;
   if (FX_REC_VARIANT_TAG(t1__0) == 6) {
      res_0 = true;
   }
   else if (FX_REC_VARIANT_TAG(t1__0) == 7) {
      res_0 = true;
   }
   else if (FX_REC_VARIANT_TAG(t1__0) == 9) {
      res_0 = true;
   }
   else {
      res_0 = false;
   }
   FX_CHECK_EXN(_fx_cleanup);
   if (res_0) {
      if (FX_REC_VARIANT_TAG(e2_0) == 6) {
         _fx_N10Ast__lit_t* v_1 = &e2_0->u.ExpLit.t0;
         if (v_1->tag == 1) {
            fx_str_t v_2 = {0};
            fx_str_t v_3 = {0};
            fx_str_t v_4 = {0};
            fx_str_t v_5 = {0};
            fx_str_t v_6 = {0};
            fx_exn_t v_7 = {0};
            int64_t i_0 = v_1->u.LitInt;
            _fx_Ta2l v_8;
            FX_CALL(_fx_M13Ast_typecheckFM14typ_bounds_intTa2l1N10Ast__typ_t(t1__0, &v_8, 0), _fx_catch_4);
            int64_t minval_0 = v_8.t0;
            int64_t maxval_0 = v_8.t1;
            bool t_0;
            if (i_0 < minval_0) {
               t_0 = true;
            }
            else {
               t_0 = i_0 > maxval_0;
            }
            if (t_0) {
               FX_CALL(_fx_F6stringS1l(i_0, &v_2, 0), _fx_catch_4);
               FX_CALL(_fx_F6stringS1l(minval_0, &v_3, 0), _fx_catch_4);
               FX_CALL(_fx_F6stringS1l(maxval_0, &v_4, 0), _fx_catch_4);
               FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t1__0, &v_5, 0), _fx_catch_4);
               fx_str_t slit_0 = FX_MAKE_STR("the literal \'");
               fx_str_t slit_1 = FX_MAKE_STR("\' is outside of the exactly-represented value range [");
               fx_str_t slit_2 = FX_MAKE_STR(", ");
               fx_str_t slit_3 = FX_MAKE_STR("] of type \'");
               fx_str_t slit_4 = FX_MAKE_STR("\'");
               {
                  const fx_str_t strs_0[] = { slit_0, v_2, slit_1, v_3, slit_2, v_4, slit_3, v_5, slit_4 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_0, 9, &v_6), _fx_catch_4);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc2_0, &v_6, &v_7, 0), _fx_catch_4);
               FX_THROW(&v_7, false, _fx_catch_4);
            }
            int tag_0 = FX_REC_VARIANT_TAG(t1__0);
            if (tag_0 == 6) {
               _fx_N10Ast__lit_t v_9 = {0};
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_10 = {0};
               _fx_M3AstFM7LitSIntN10Ast__lit_t2il(t1__0->u.TypSInt, i_0, &v_9);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t1_0, &eloc2_0, &v_10);
               FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_9, &v_10, fx_result),
                  _fx_catch_0);

            _fx_catch_0: ;
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_10);
               _fx_free_N10Ast__lit_t(&v_9);
            }
            else if (tag_0 == 7) {
               _fx_N10Ast__lit_t v_11 = {0};
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_12 = {0};
               _fx_M3AstFM7LitUIntN10Ast__lit_t2iq(t1__0->u.TypUInt, (uint64_t)i_0, &v_11);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t1_0, &eloc2_0, &v_12);
               FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_11, &v_12, fx_result),
                  _fx_catch_1);

            _fx_catch_1: ;
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_12);
               _fx_free_N10Ast__lit_t(&v_11);
            }
            else if (tag_0 == 9) {
               _fx_N10Ast__lit_t v_13 = {0};
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_14 = {0};
               _fx_M3AstFM8LitFloatN10Ast__lit_t2id(t1__0->u.TypFloat, (double)i_0, &v_13);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t1_0, &eloc2_0, &v_14);
               FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_13, &v_14, fx_result),
                  _fx_catch_2);

            _fx_catch_2: ;
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_14);
               _fx_free_N10Ast__lit_t(&v_13);
            }
            else {
               fx_str_t v_15 = {0};
               fx_str_t v_16 = {0};
               fx_exn_t v_17 = {0};
               FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t1__0, &v_15, 0), _fx_catch_3);
               fx_str_t slit_5 = FX_MAKE_STR("unexpected type \'");
               fx_str_t slit_6 = FX_MAKE_STR("\'; TypSInt(_), TypUInt(_) or TypFloat(_) is expected");
               {
                  const fx_str_t strs_1[] = { slit_5, v_15, slit_6 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_1, 3, &v_16), _fx_catch_3);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc2_0, &v_16, &v_17, 0), _fx_catch_3);
               FX_THROW(&v_17, false, _fx_catch_3);

            _fx_catch_3: ;
               fx_free_exn(&v_17);
               FX_FREE_STR(&v_16);
               FX_FREE_STR(&v_15);
            }
            FX_CHECK_EXN(_fx_catch_4);

         _fx_catch_4: ;
            fx_free_exn(&v_7);
            FX_FREE_STR(&v_6);
            FX_FREE_STR(&v_5);
            FX_FREE_STR(&v_4);
            FX_FREE_STR(&v_3);
            FX_FREE_STR(&v_2);
            goto _fx_endmatch_0;
         }
      }
   }
   if (FX_REC_VARIANT_TAG(e2_0) == 13) {
      if (FX_REC_VARIANT_TAG(t1__0) == 17) {
         fx_str_t v_18 = {0};
         fx_str_t v_19 = {0};
         fx_str_t v_20 = {0};
         fx_exn_t v_21 = {0};
         _fx_T2LN10Ast__exp_tLN10Ast__typ_t v_22 = {0};
         _fx_LN10Ast__exp_t lst_0 = 0;
         _fx_LN10Ast__typ_t lst_1 = 0;
         _fx_LN10Ast__typ_t tl_0 = 0;
         _fx_LN10Ast__exp_t el_0 = 0;
         _fx_LN10Ast__exp_t el_1 = 0;
         _fx_LN10Ast__typ_t tl_1 = 0;
         _fx_N10Ast__typ_t v_23 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_24 = {0};
         _fx_LN10Ast__typ_t tl_2 = t1__0->u.TypTuple;
         _fx_LN10Ast__exp_t el_2 = e2_0->u.ExpMkTuple.t0;
         int_ nt_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(tl_2, 0);
         int_ nexp_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__exp_t(el_2, 0);
         if (nt_0 != nexp_0) {
            FX_CALL(_fx_F6stringS1i(nt_0, &v_18, 0), _fx_catch_6);
            FX_CALL(_fx_F6stringS1i(nexp_0, &v_19, 0), _fx_catch_6);
            fx_str_t slit_7 = FX_MAKE_STR("the tuple type is supposed to have ");
            fx_str_t slit_8 = FX_MAKE_STR(" elements, whereas the constructed tuple has ");
            fx_str_t slit_9 = FX_MAKE_STR(" elements");
            {
               const fx_str_t strs_2[] = { slit_7, v_18, slit_8, v_19, slit_9 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_2, 5, &v_20), _fx_catch_6);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc2_0, &v_20, &v_21, 0), _fx_catch_6);
            FX_THROW(&v_21, false, _fx_catch_6);
         }
         _fx_LN10Ast__exp_t lstend_0 = 0;
         _fx_LN10Ast__typ_t lstend_1 = 0;
         FX_COPY_PTR(tl_2, &tl_0);
         _fx_LN10Ast__typ_t lst_2 = tl_0;
         FX_COPY_PTR(el_2, &el_0);
         _fx_LN10Ast__exp_t lst_3 = el_0;
         for (; lst_2 && lst_3; lst_3 = lst_3->tl, lst_2 = lst_2->tl) {
            _fx_N10Ast__exp_t e_0 = 0;
            _fx_N10Ast__typ_t t_1 = 0;
            _fx_T2N10Ast__exp_tN10Ast__typ_t tup_0 = {0};
            _fx_N10Ast__exp_t e_1 = lst_3->hd;
            _fx_N10Ast__typ_t t_2 = lst_2->hd;
            FX_CALL(
               _fx_M13Ast_typecheckFM22try_unify_with_literalN10Ast__exp_t3N10Ast__typ_tN10Ast__exp_tS(t_2, e_1, msg_0, &e_0,
                  0), _fx_catch_5);
            FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(e_0, &t_1, 0), _fx_catch_5);
            _fx_make_T2N10Ast__exp_tN10Ast__typ_t(e_0, t_1, &tup_0);
            _fx_LN10Ast__exp_t node_0 = 0;
            FX_CALL(_fx_cons_LN10Ast__exp_t(tup_0.t0, 0, false, &node_0), _fx_catch_5);
            FX_LIST_APPEND(lst_0, lstend_0, node_0);
            _fx_LN10Ast__typ_t node_1 = 0;
            FX_CALL(_fx_cons_LN10Ast__typ_t(tup_0.t1, 0, false, &node_1), _fx_catch_5);
            FX_LIST_APPEND(lst_1, lstend_1, node_1);

         _fx_catch_5: ;
            _fx_free_T2N10Ast__exp_tN10Ast__typ_t(&tup_0);
            if (t_1) {
               _fx_free_N10Ast__typ_t(&t_1);
            }
            if (e_0) {
               _fx_free_N10Ast__exp_t(&e_0);
            }
            FX_CHECK_EXN(_fx_catch_6);
         }
         int s_0 = !lst_2 + !lst_3;
         FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_6);
         _fx_make_T2LN10Ast__exp_tLN10Ast__typ_t(lst_0, lst_1, &v_22);
         FX_COPY_PTR(v_22.t0, &el_1);
         FX_COPY_PTR(v_22.t1, &tl_1);
         FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(tl_1, &v_23), _fx_catch_6);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_23, &eloc2_0, &v_24);
         FX_CALL(_fx_M3AstFM10ExpMkTupleN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(el_1, &v_24, fx_result),
            _fx_catch_6);

      _fx_catch_6: ;
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_24);
         if (v_23) {
            _fx_free_N10Ast__typ_t(&v_23);
         }
         if (tl_1) {
            _fx_free_LN10Ast__typ_t(&tl_1);
         }
         if (el_1) {
            _fx_free_LN10Ast__exp_t(&el_1);
         }
         if (el_0) {
            _fx_free_LN10Ast__exp_t(&el_0);
         }
         if (tl_0) {
            _fx_free_LN10Ast__typ_t(&tl_0);
         }
         if (lst_1) {
            _fx_free_LN10Ast__typ_t(&lst_1);
         }
         if (lst_0) {
            _fx_free_LN10Ast__exp_t(&lst_0);
         }
         _fx_free_T2LN10Ast__exp_tLN10Ast__typ_t(&v_22);
         fx_free_exn(&v_21);
         FX_FREE_STR(&v_20);
         FX_FREE_STR(&v_19);
         FX_FREE_STR(&v_18);
         goto _fx_endmatch_0;
      }
   }
   fx_exn_t v_25 = {0};
   bool v_26;
   FX_CALL(_fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t1_0, t2_0, &eloc2_0, true, &v_26, 0),
      _fx_catch_7);
   if (!v_26) {
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc2_0, msg_0, &v_25, 0), _fx_catch_7); FX_THROW(&v_25, false, _fx_catch_7);
   }
   FX_COPY_PTR(e2_0, fx_result);

_fx_catch_7: ;
   fx_free_exn(&v_25);

_fx_endmatch_0: ;

_fx_cleanup: ;
   if (t1__0) {
      _fx_free_N10Ast__typ_t(&t1__0);
   }
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_0);
   if (t2_0) {
      _fx_free_N10Ast__typ_t(&t2_0);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM19finalize_record_typN10Ast__typ_t4Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t v_0 = 0;
   _fx_N10Ast__typ_t t_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_CALL(_fx_M3AstFM7dup_typN10Ast__typ_t1N10Ast__typ_t(t_0, &v_0, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(v_0, &t_1, 0), _fx_cleanup);
   if (FX_REC_VARIANT_TAG(t_1) == 20) {
      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_1 = {0};
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_0 = 0;
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_1 = 0;
      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_2 = {0};
      _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB r_0 = t_1->u.TypRecord;
      _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&r_0->data, &v_1);
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lstend_0 = 0;
      FX_COPY_PTR(v_1.t0, &relems_1);
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_0 = relems_1;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_R16Ast__val_flags_t flags_0 = {0};
         _fx_N10Ast__typ_t t_2 = 0;
         _fx_N10Ast__exp_t v0_0 = 0;
         _fx_N10Ast__exp_t v0_1 = 0;
         _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t tup_0 = {0};
         _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___0 = &lst_0->hd;
         _fx_copy_R16Ast__val_flags_t(&__pat___0->t0, &flags_0);
         _fx_R9Ast__id_t n_0 = __pat___0->t1;
         FX_COPY_PTR(__pat___0->t2, &t_2);
         FX_COPY_PTR(__pat___0->t3, &v0_0);
         int tag_0 = FX_REC_VARIANT_TAG(v0_0);
         if (tag_0 == 1) {
            FX_COPY_PTR(v0_0, &v0_1);
         }
         else if (tag_0 == 6) {
            _fx_N10Ast__typ_t t0_0 = 0;
            fx_exn_t v_3 = {0};
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_4 = {0};
            _fx_Nt6option1N10Ast__lit_t v_opt_0 = {0};
            _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t* vcase_0 = &v0_0->u.ExpLit;
            _fx_T2N10Ast__typ_tR10Ast__loc_t* v_5 = &vcase_0->t1;
            _fx_R10Ast__loc_t* lloc_0 = &v_5->t1;
            _fx_N10Ast__typ_t lt_0 = v_5->t0;
            _fx_N10Ast__lit_t* v_6 = &vcase_0->t0;
            FX_CALL(_fx_M3AstFM11get_lit_typN10Ast__typ_t1N10Ast__lit_t(v_6, &t0_0, 0), _fx_catch_5);
            bool v_7;
            FX_CALL(
               _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t_2, t0_0, loc_0, true, &v_7, 0),
               _fx_catch_5);
            if (v_7) {
               bool v_8;
               FX_CALL(
                  _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t0_0, lt_0, lloc_0, true, &v_8,
                     0), _fx_catch_5);
               if (!v_8) {
                  fx_str_t slit_0 = FX_MAKE_STR("inconsistent literal type");
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(lloc_0, &slit_0, &v_3, 0), _fx_catch_5);
                  FX_THROW(&v_3, false, _fx_catch_5);
               }
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(lt_0, lloc_0, &v_4);
               FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(v_6, &v_4, &v0_1), _fx_catch_5);
            }
            else {
               int tag_1 = v_6->tag;
               if (tag_1 == 1) {
                  int64_t iv_0 = v_6->u.LitInt;
                  _fx_Ta2l v_9;
                  FX_CALL(_fx_M13Ast_typecheckFM14typ_bounds_intTa2l1N10Ast__typ_t(t_2, &v_9, 0), _fx_catch_0);
                  int64_t a_0 = v_9.t0;
                  int64_t b_0 = v_9.t1;
                  if ((bool)((a_0 <= iv_0) & (iv_0 <= b_0))) {
                     int tag_2 = FX_REC_VARIANT_TAG(t_2);
                     if (tag_2 == 6) {
                        _fx_N10Ast__lit_t v_10 = {0};
                        _fx_M3AstFM7LitSIntN10Ast__lit_t2il(t_2->u.TypSInt, iv_0, &v_10);
                        _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__lit_t1N10Ast__lit_t(&v_10, &v_opt_0);
                        _fx_free_N10Ast__lit_t(&v_10);
                     }
                     else if (tag_2 == 7) {
                        _fx_N10Ast__lit_t v_11 = {0};
                        _fx_M3AstFM7LitUIntN10Ast__lit_t2iq(t_2->u.TypUInt, (uint64_t)iv_0, &v_11);
                        _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__lit_t1N10Ast__lit_t(&v_11, &v_opt_0);
                        _fx_free_N10Ast__lit_t(&v_11);
                     }
                     else if (tag_2 == 9) {
                        _fx_N10Ast__lit_t v_12 = {0};
                        _fx_M3AstFM8LitFloatN10Ast__lit_t2id(t_2->u.TypFloat, (double)iv_0, &v_12);
                        _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__lit_t1N10Ast__lit_t(&v_12, &v_opt_0);
                        _fx_free_N10Ast__lit_t(&v_12);
                     }
                     else {
                        _fx_copy_Nt6option1N10Ast__lit_t(&_fx_g21Ast_typecheck__None3_, &v_opt_0);
                     }
                     FX_CHECK_EXN(_fx_catch_0);
                  }
                  else {
                     _fx_copy_Nt6option1N10Ast__lit_t(&_fx_g21Ast_typecheck__None3_, &v_opt_0);
                  }

               _fx_catch_0: ;
                  goto _fx_endmatch_1;
               }
               if (tag_1 == 4) {
                  _fx_T2id* vcase_1 = &v_6->u.LitFloat;
                  if (vcase_1->t0 == 64) {
                     double fv_0 = vcase_1->t1;
                     if (FX_REC_VARIANT_TAG(t_2) == 9) {
                        _fx_N10Ast__lit_t v_13 = {0};
                        int tag_3 = FX_REC_VARIANT_TAG(t_2);
                        double a_1;
                        if (tag_3 == 9) {
                           if (t_2->u.TypFloat == 16) {
                              a_1 = 65504.0; goto _fx_endmatch_0;
                           }
                        }
                        if (tag_3 == 9) {
                           if (t_2->u.TypFloat == 32) {
                              a_1 = 3.402823e+38; goto _fx_endmatch_0;
                           }
                        }
                        a_1 = 0.0;

                     _fx_endmatch_0: ;
                        FX_CHECK_EXN(_fx_catch_1);
                        bool t_3;
                        if (a_1 > 0.0) {
                           t_3 = (bool)((-a_1 <= fv_0) & (fv_0 <= a_1));
                        }
                        else {
                           t_3 = false;
                        }
                        if (t_3) {
                           _fx_M3AstFM8LitFloatN10Ast__lit_t2id(t_2->u.TypFloat, fv_0, &v_13);
                           _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__lit_t1N10Ast__lit_t(&v_13, &v_opt_0);
                        }
                        else {
                           _fx_copy_Nt6option1N10Ast__lit_t(&_fx_g21Ast_typecheck__None3_, &v_opt_0);
                        }

                     _fx_catch_1: ;
                        _fx_free_N10Ast__lit_t(&v_13);
                     }
                     else {
                        _fx_copy_Nt6option1N10Ast__lit_t(&_fx_g21Ast_typecheck__None3_, &v_opt_0);
                     }
                     FX_CHECK_EXN(_fx_catch_2);

                  _fx_catch_2: ;
                     goto _fx_endmatch_1;
                  }
               }
               _fx_copy_Nt6option1N10Ast__lit_t(&_fx_g21Ast_typecheck__None3_, &v_opt_0);

            _fx_endmatch_1: ;
               FX_CHECK_EXN(_fx_catch_5);
               if (v_opt_0.tag == 2) {
                  _fx_T2N10Ast__typ_tR10Ast__loc_t v_14 = {0};
                  _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t_2, lloc_0, &v_14);
                  FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_opt_0.u.Some, &v_14, &v0_1),
                     _fx_catch_3);

               _fx_catch_3: ;
                  _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_14);
               }
               else {
                  fx_str_t v_15 = {0};
                  fx_str_t v_16 = {0};
                  fx_str_t v_17 = {0};
                  fx_str_t v_18 = {0};
                  fx_exn_t v_19 = {0};
                  FX_CALL(_fx_M3AstFM7lit2strS1N10Ast__lit_t(v_6, &v_15, 0), _fx_catch_4);
                  FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t_2, &v_16, 0), _fx_catch_4);
                  FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&n_0, &v_17, 0), _fx_catch_4);
                  fx_str_t slit_1 = FX_MAKE_STR("the literal ");
                  fx_str_t slit_2 = FX_MAKE_STR(" cannot be casted implicitly to the type \'");
                  fx_str_t slit_3 = FX_MAKE_STR("\' of the record member \'");
                  fx_str_t slit_4 = FX_MAKE_STR("\'");
                  {
                     const fx_str_t strs_0[] = { slit_1, v_15, slit_2, v_16, slit_3, v_17, slit_4 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_0, 7, &v_18), _fx_catch_4);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_18, &v_19, 0), _fx_catch_4);
                  FX_THROW(&v_19, false, _fx_catch_4);

               _fx_catch_4: ;
                  fx_free_exn(&v_19);
                  FX_FREE_STR(&v_18);
                  FX_FREE_STR(&v_17);
                  FX_FREE_STR(&v_16);
                  FX_FREE_STR(&v_15);
               }
               FX_CHECK_EXN(_fx_catch_5);
            }

         _fx_catch_5: ;
            _fx_free_Nt6option1N10Ast__lit_t(&v_opt_0);
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_4);
            fx_free_exn(&v_3);
            if (t0_0) {
               _fx_free_N10Ast__typ_t(&t0_0);
            }
         }
         else {
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_20 = {0};
            _fx_N10Ast__typ_t ti_0 = 0;
            fx_exn_t v_21 = {0};
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(v0_0, &v_20, 0), _fx_catch_6);
            FX_COPY_PTR(v_20.t0, &ti_0);
            _fx_R10Ast__loc_t loci_0 = v_20.t1;
            bool v_22;
            FX_CALL(
               _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(ti_0, t_2, &loci_0, true, &v_22,
                  0), _fx_catch_6);
            if (!v_22) {
               fx_str_t slit_5 = FX_MAKE_STR("the actual type of the default expression does not match the specified type");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&loci_0, &slit_5, &v_21, 0), _fx_catch_6);
               FX_THROW(&v_21, false, _fx_catch_6);
            }
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  v0_0, env_0, sc_0, &v0_1, 0), _fx_catch_6);

         _fx_catch_6: ;
            fx_free_exn(&v_21);
            if (ti_0) {
               _fx_free_N10Ast__typ_t(&ti_0);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_20);
         }
         FX_CHECK_EXN(_fx_catch_7);
         _fx_make_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&flags_0, &n_0, t_2, v0_1, &tup_0);
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t node_0 = 0;
         FX_CALL(_fx_cons_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&tup_0, 0, false, &node_0), _fx_catch_7);
         FX_LIST_APPEND(relems_0, lstend_0, node_0);

      _fx_catch_7: ;
         _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&tup_0);
         if (v0_1) {
            _fx_free_N10Ast__exp_t(&v0_1);
         }
         if (v0_0) {
            _fx_free_N10Ast__exp_t(&v0_0);
         }
         if (t_2) {
            _fx_free_N10Ast__typ_t(&t_2);
         }
         _fx_free_R16Ast__val_flags_t(&flags_0);
         FX_CHECK_EXN(_fx_catch_8);
      }
      _fx_make_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(relems_0, v_1.t1, &v_2);
      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB* v_23 = &r_0->data;
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(v_23);
      _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_2, v_23);
      FX_COPY_PTR(t_1, fx_result);

   _fx_catch_8: ;
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_2);
      if (relems_1) {
         _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_1);
      }
      if (relems_0) {
         _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_0);
      }
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_1);
   }
   else {
      FX_COPY_PTR(t_1, fx_result);
   }

_fx_cleanup: ;
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   if (t_1) {
      _fx_free_N10Ast__typ_t(&t_1);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM17find_typ_instanceNt6option1N10Ast__typ_t2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t t_1 = 0;
   int fx_status = 0;
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t_0, &t_1, 0), _fx_cleanup);
   if (FX_REC_VARIANT_TAG(t_1) == 24) {
      _fx_N14Ast__id_info_t v_0 = {0};
      _fx_LR9Ast__id_t inst_list_0 = 0;
      _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_0 = &t_1->u.TypApp;
      if (vcase_0->t0 == 0) {
         FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t_1, fx_result), _fx_catch_3);
      }
      else {
         FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&vcase_0->t1, loc_0, &v_0, 0), _fx_catch_3);
         if (v_0.tag == 6) {
            _fx_R17Ast__defvariant_t v_1 = {0};
            _fx_copy_R17Ast__defvariant_t(&v_0.u.IdVariant->data, &v_1);
            FX_COPY_PTR(v_1.dvar_templ_inst->data, &inst_list_0);
            _fx_free_R17Ast__defvariant_t(&v_1);
         }
         FX_CHECK_EXN(_fx_catch_3);
         _fx_Nt6option1R9Ast__id_t __fold_result___0 = _fx_g21Ast_typecheck__None9_;
         _fx_LR9Ast__id_t lst_0 = inst_list_0;
         for (; lst_0; lst_0 = lst_0->tl) {
            _fx_N14Ast__id_info_t v_2 = {0};
            _fx_R9Ast__id_t* inst_0 = &lst_0->hd;
            FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(inst_0, loc_0, &v_2, 0), _fx_catch_1);
            bool v_3;
            if (v_2.tag == 6) {
               _fx_R17Ast__defvariant_t v_4 = {0};
               _fx_copy_R17Ast__defvariant_t(&v_2.u.IdVariant->data, &v_4);
               FX_CALL(
                  _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t_1, v_4.dvar_alias, loc_0,
                     false, &v_3, 0), _fx_catch_0);

            _fx_catch_0: ;
               _fx_free_R17Ast__defvariant_t(&v_4);
            }
            else {
               v_3 = false;
            }
            FX_CHECK_EXN(_fx_catch_1);
            if (v_3) {
               _fx_Nt6option1R9Ast__id_t v_5;
               _fx_M13Ast_typecheckFM4SomeNt6option1R9Ast__id_t1R9Ast__id_t(inst_0, &v_5);
               __fold_result___0 = v_5;
               FX_BREAK(_fx_catch_1);
            }

         _fx_catch_1: ;
            _fx_free_N14Ast__id_info_t(&v_2);
            FX_CHECK_BREAK();
            FX_CHECK_EXN(_fx_catch_3);
         }
         _fx_Nt6option1R9Ast__id_t __fold_result___1 = __fold_result___0;
         if (__fold_result___1.tag == 2) {
            _fx_N10Ast__typ_t v_6 = 0;
            FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, &__fold_result___1.u.Some, &v_6), _fx_catch_2);
            FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(v_6, fx_result), _fx_catch_2);

         _fx_catch_2: ;
            if (v_6) {
               _fx_free_N10Ast__typ_t(&v_6);
            }
         }
         else {
            FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, fx_result);
         }
         FX_CHECK_EXN(_fx_catch_3);
      }

   _fx_catch_3: ;
      FX_FREE_LIST_SIMPLE(&inst_list_0);
      _fx_free_N14Ast__id_info_t(&v_0);
   }
   else {
      FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(t_1, fx_result), _fx_catch_4);  _fx_catch_4: ;
   }

_fx_cleanup: ;
   if (t_1) {
      _fx_free_N10Ast__typ_t(&t_1);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM16get_record_elemsT2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t4Nt6option1R9Ast__id_tN10Ast__typ_tBR10Ast__loc_t(
   struct _fx_Nt6option1R9Ast__id_t* vn_opt_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   bool proto_mode_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t t_1 = 0;
   _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_0 = {0};
   int fx_status = 0;
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t_0, &t_1, 0), _fx_cleanup);
   _fx_R9Ast__id_t input_vn_0;
   if (vn_opt_0->tag == 2) {
      FX_CALL(_fx_M3AstFM13get_bare_nameRM4id_t1RM4id_t(&vn_opt_0->u.Some, &input_vn_0, 0), _fx_catch_0);  _fx_catch_0: ;
   }
   else {
      input_vn_0 = _fx_g9Ast__noid;
   }
   FX_CHECK_EXN(_fx_cleanup);
   int tag_0 = FX_REC_VARIANT_TAG(t_1);
   if (tag_0 == 20) {
      _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&t_1->u.TypRecord->data, &v_0);
      if (v_0.t1 == true) {
         _fx_make_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&_fx_g9Ast__noid, v_0.t0, fx_result);
         goto _fx_endmatch_4;
      }
   }
   if (tag_0 == 20) {
      fx_exn_t v_1 = {0};
      fx_str_t slit_0 = FX_MAKE_STR("the records, which elements we request, is not finalized");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_0, &v_1, 0), _fx_catch_1);
      FX_THROW(&v_1, false, _fx_catch_1);

   _fx_catch_1: ;
      fx_free_exn(&v_1);
      goto _fx_endmatch_4;
   }
   if (tag_0 == 24) {
      _fx_T2LN10Ast__typ_tR9Ast__id_t v_2 = {0};
      _fx_Nt6option1N10Ast__typ_t v_3 = 0;
      _fx_LN10Ast__typ_t new_tyargs_0 = 0;
      _fx_N14Ast__id_info_t v_4 = {0};
      _fx_R17Ast__defvariant_t v_5 = {0};
      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_6 = {0};
      _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_0 = &t_1->u.TypApp;
      if (proto_mode_0) {
         _fx_make_T2LN10Ast__typ_tR9Ast__id_t(vcase_0->t0, &vcase_0->t1, &v_2);
      }
      else {
         FX_CALL(
            _fx_M13Ast_typecheckFM17find_typ_instanceNt6option1N10Ast__typ_t2N10Ast__typ_tR10Ast__loc_t(t_1, loc_0, &v_3, 0),
            _fx_catch_8);
         if ((v_3 != 0) + 1 == 2) {
            _fx_N10Ast__typ_t v_7 = v_3->u.Some;
            if (FX_REC_VARIANT_TAG(v_7) == 24) {
               _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_1 = &v_7->u.TypApp;
               if (vcase_1->t0 == 0) {
                  _fx_make_T2LN10Ast__typ_tR9Ast__id_t(0, &vcase_1->t1, &v_2); goto _fx_endmatch_0;
               }
            }
         }
         fx_exn_t v_8 = {0};
         fx_str_t slit_1 = FX_MAKE_STR("proper instance of the template record or variant type is not found");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_1, &v_8, 0), _fx_catch_2);
         FX_THROW(&v_8, false, _fx_catch_2);

      _fx_catch_2: ;
         fx_free_exn(&v_8);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_8);
      }
      FX_COPY_PTR(v_2.t0, &new_tyargs_0);
      _fx_R9Ast__id_t n_0 = v_2.t1;
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&n_0, loc_0, &v_4, 0), _fx_catch_8);
      int tag_1 = v_4.tag;
      if (tag_1 == 6) {
         _fx_copy_R17Ast__defvariant_t(&v_4.u.IdVariant->data, &v_5);
         _fx_LT2R9Ast__id_tN10Ast__typ_t v_9 = v_5.dvar_cases;
         if (v_9 != 0) {
            if (v_9->tl == 0) {
               _fx_T2R9Ast__id_tN10Ast__typ_t* v_10 = &v_9->hd;
               _fx_N10Ast__typ_t v_11 = v_10->t1;
               if (FX_REC_VARIANT_TAG(v_11) == 20) {
                  _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_11->u.TypRecord->data, &v_6);
                  if (v_6.t1 == true) {
                     _fx_R9Ast__id_t* vn0_0 = &v_10->t0;
                     if (v_5.dvar_flags.var_flag_record) {
                        _fx_LN10Ast__typ_t res_0 = 0;
                        fx_str_t v_12 = {0};
                        fx_str_t v_13 = {0};
                        fx_str_t v_14 = {0};
                        fx_exn_t v_15 = {0};
                        FX_CALL(
                           _fx_M13Ast_typecheckFM21check_and_norm_tyargsLN10Ast__typ_t4LN10Ast__typ_tLR9Ast__id_tR10Ast__loc_tR10Ast__loc_t(
                              new_tyargs_0, v_5.dvar_templ_args, &v_5.dvar_loc, loc_0, &res_0, 0), _fx_catch_3);
                        bool res_1;
                        FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&input_vn_0, &_fx_g9Ast__noid, &res_1, 0), _fx_catch_3);
                        bool t_2;
                        if (!res_1) {
                           _fx_R9Ast__id_t v_16;
                           FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(vn0_0, &v_16, 0), _fx_catch_3);
                           bool res_2;
                           FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&input_vn_0, &v_16, &res_2, 0), _fx_catch_3);
                           t_2 = !res_2;
                        }
                        else {
                           t_2 = false;
                        }
                        if (t_2) {
                           FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&input_vn_0, &v_12, 0), _fx_catch_3);
                           FX_CALL(_fx_M3AstFM2ppS1RM4id_t(vn0_0, &v_13, 0), _fx_catch_3);
                           fx_str_t slit_2 = FX_MAKE_STR("mismatch in the record name: given \'");
                           fx_str_t slit_3 = FX_MAKE_STR("\', expected \'");
                           fx_str_t slit_4 = FX_MAKE_STR("\'");
                           {
                              const fx_str_t strs_0[] = { slit_2, v_12, slit_3, v_13, slit_4 };
                              FX_CALL(fx_strjoin(0, 0, 0, strs_0, 5, &v_14), _fx_catch_3);
                           }
                           FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_14, &v_15, 0), _fx_catch_3);
                           FX_THROW(&v_15, false, _fx_catch_3);
                        }
                        _fx_make_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&_fx_g9Ast__noid,
                           v_6.t0, fx_result);

                     _fx_catch_3: ;
                        fx_free_exn(&v_15);
                        FX_FREE_STR(&v_14);
                        FX_FREE_STR(&v_13);
                        FX_FREE_STR(&v_12);
                        if (res_0) {
                           _fx_free_LN10Ast__typ_t(&res_0);
                        }
                        goto _fx_endmatch_3;
                     }
                  }
               }
            }
         }
      }
      if (tag_1 == 6) {
         _fx_R17Ast__defvariant_t v_17 = {0};
         _fx_LN10Ast__typ_t res_3 = 0;
         _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t __fold_result___0 = {0};
         _fx_LT2R9Ast__id_tN10Ast__typ_t dvar_cases_0 = 0;
         _fx_LR9Ast__id_t dvar_ctors_0 = 0;
         _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t found_case_ctor_0 = {0};
         _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_18 = {0};
         _fx_copy_R17Ast__defvariant_t(&v_4.u.IdVariant->data, &v_17);
         _fx_LT2R9Ast__id_tN10Ast__typ_t dvar_cases_1 = v_17.dvar_cases;
         _fx_R9Ast__id_t* dvar_name_0 = &v_17.dvar_name;
         FX_CALL(
            _fx_M13Ast_typecheckFM21check_and_norm_tyargsLN10Ast__typ_t4LN10Ast__typ_tLR9Ast__id_tR10Ast__loc_tR10Ast__loc_t(
               new_tyargs_0, v_17.dvar_templ_args, &v_17.dvar_loc, loc_0, &res_3, 0), _fx_catch_6);
         bool single_case_0;
         if (dvar_cases_1 != 0) {
            if (dvar_cases_1->tl == 0) {
               single_case_0 = true; goto _fx_endmatch_1;
            }
         }
         single_case_0 = false;

      _fx_endmatch_1: ;
         FX_CHECK_EXN(_fx_catch_6);
         _fx_copy_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&_fx_g21Ast_typecheck__None2_, &__fold_result___0);
         FX_COPY_PTR(dvar_cases_1, &dvar_cases_0);
         _fx_LT2R9Ast__id_tN10Ast__typ_t lst_0 = dvar_cases_0;
         FX_COPY_PTR(v_17.dvar_ctors, &dvar_ctors_0);
         _fx_LR9Ast__id_t lst_1 = dvar_ctors_0;
         for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl) {
            _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t v_19 = {0};
            _fx_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t v_20 = {0};
            _fx_R9Ast__id_t* c_id_0 = &lst_1->hd;
            _fx_T2R9Ast__id_tN10Ast__typ_t* __pat___0 = &lst_0->hd;
            _fx_R9Ast__id_t vn_0 = __pat___0->t0;
            _fx_R9Ast__id_t v_21;
            FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&vn_0, &v_21, 0), _fx_catch_4);
            bool res_4;
            FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_21, &input_vn_0, &res_4, 0), _fx_catch_4);
            bool t_3;
            if (res_4) {
               t_3 = true;
            }
            else if (single_case_0) {
               FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&input_vn_0, &_fx_g9Ast__noid, &t_3, 0), _fx_catch_4);
            }
            else {
               t_3 = false;
            }
            if (t_3) {
               _fx_make_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(__pat___0, c_id_0, &v_19);
               _fx_M13Ast_typecheckFM4SomeNt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(
                  &v_19, &v_20);
               _fx_free_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&__fold_result___0);
               _fx_copy_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&v_20, &__fold_result___0);
               FX_BREAK(_fx_catch_4);
            }

         _fx_catch_4: ;
            _fx_free_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&v_20);
            _fx_free_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&v_19);
            FX_CHECK_BREAK();
            FX_CHECK_EXN(_fx_catch_6);
         }
         int s_0 = !lst_0 + !lst_1;
         FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_6);
         _fx_copy_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&__fold_result___0, &found_case_ctor_0);
         if (found_case_ctor_0.tag == 2) {
            _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t* v_22 = &found_case_ctor_0.u.Some;
            _fx_N10Ast__typ_t v_23 = v_22->t0.t1;
            if (FX_REC_VARIANT_TAG(v_23) == 20) {
               _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_23->u.TypRecord->data, &v_18);
               if (v_18.t1 == true) {
                  _fx_make_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_22->t1, v_18.t0,
                     fx_result);
                  goto _fx_endmatch_2;
               }
            }
         }
         fx_str_t msg_0 = {0};
         fx_str_t v_24 = {0};
         fx_str_t v_25 = {0};
         fx_str_t v_26 = {0};
         fx_exn_t v_27 = {0};
         bool res_5;
         FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&input_vn_0, &_fx_g9Ast__noid, &res_5, 0), _fx_catch_5);
         if (res_5) {
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(dvar_name_0, &v_24, 0), _fx_catch_5);
            fx_str_t slit_5 = FX_MAKE_STR("variant \'");
            fx_str_t slit_6 = FX_MAKE_STR("\' is not a record");
            {
               const fx_str_t strs_1[] = { slit_5, v_24, slit_6 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_1, 3, &msg_0), _fx_catch_5);
            }
         }
         else {
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&input_vn_0, &v_25, 0), _fx_catch_5);
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(dvar_name_0, &v_26, 0), _fx_catch_5);
            fx_str_t slit_7 = FX_MAKE_STR("\'");
            fx_str_t slit_8 = FX_MAKE_STR("\' is not found in \'");
            fx_str_t slit_9 = FX_MAKE_STR("\'");
            {
               const fx_str_t strs_2[] = { slit_7, v_25, slit_8, v_26, slit_9 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_2, 5, &msg_0), _fx_catch_5);
            }
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &msg_0, &v_27, 0), _fx_catch_5);
         FX_THROW(&v_27, false, _fx_catch_5);

      _fx_catch_5: ;
         fx_free_exn(&v_27);
         FX_FREE_STR(&v_26);
         FX_FREE_STR(&v_25);
         FX_FREE_STR(&v_24);
         FX_FREE_STR(&msg_0);

      _fx_endmatch_2: ;
         FX_CHECK_EXN(_fx_catch_6);

      _fx_catch_6: ;
         _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_18);
         _fx_free_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&found_case_ctor_0);
         FX_FREE_LIST_SIMPLE(&dvar_ctors_0);
         if (dvar_cases_0) {
            _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&dvar_cases_0);
         }
         _fx_free_Nt6option1T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&__fold_result___0);
         if (res_3) {
            _fx_free_LN10Ast__typ_t(&res_3);
         }
         _fx_free_R17Ast__defvariant_t(&v_17);
         goto _fx_endmatch_3;
      }
      fx_str_t v_28 = {0};
      fx_str_t v_29 = {0};
      fx_exn_t v_30 = {0};
      FX_CALL(_fx_M3AstFM6stringS1RM4id_t(&n_0, &v_28, 0), _fx_catch_7);
      fx_str_t slit_10 = FX_MAKE_STR("cannot find a proper record constructor in type \'");
      fx_str_t slit_11 = FX_MAKE_STR("\'");
      {
         const fx_str_t strs_3[] = { slit_10, v_28, slit_11 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_3, 3, &v_29), _fx_catch_7);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_29, &v_30, 0), _fx_catch_7);
      FX_THROW(&v_30, false, _fx_catch_7);

   _fx_catch_7: ;
      fx_free_exn(&v_30);
      FX_FREE_STR(&v_29);
      FX_FREE_STR(&v_28);

   _fx_endmatch_3: ;
      FX_CHECK_EXN(_fx_catch_8);

   _fx_catch_8: ;
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_6);
      _fx_free_R17Ast__defvariant_t(&v_5);
      _fx_free_N14Ast__id_info_t(&v_4);
      if (new_tyargs_0) {
         _fx_free_LN10Ast__typ_t(&new_tyargs_0);
      }
      if (v_3) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_3);
      }
      _fx_free_T2LN10Ast__typ_tR9Ast__id_t(&v_2);
      goto _fx_endmatch_4;
   }
   fx_exn_t v_31 = {0};
   fx_str_t slit_12 = FX_MAKE_STR("attempt to treat non-record and non-variant as a record");
   FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_12, &v_31, 0), _fx_catch_9);
   FX_THROW(&v_31, false, _fx_catch_9);

_fx_catch_9: ;
   fx_free_exn(&v_31);

_fx_endmatch_4: ;

_fx_cleanup: ;
   if (t_1) {
      _fx_free_N10Ast__typ_t(&t_1);
   }
   _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM11is_real_typB1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_rB have_typ_vars_ref_0 = 0;
   _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t is_real_typ__0 = {0};
   _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t v_0 = 0;
   _fx_R16Ast__ast_callb_t callb_0 = {0};
   _fx_N10Ast__typ_t res_0 = 0;
   _fx_Nt6option1N10Ast__typ_t v_1 = 0;
   int fx_status = 0;
   FX_CALL(_fx_make_rB(false, &have_typ_vars_ref_0), _fx_cleanup);
   bool* have_typ_vars_0 = &have_typ_vars_ref_0->data;
   _fx_M13Ast_typecheckFM7make_fpFPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t1rB(have_typ_vars_ref_0, &is_real_typ__0);
   FX_CALL(
      _fx_M13Ast_typecheckFM4SomeNt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
         &is_real_typ__0, &v_0), _fx_cleanup);
   _fx_make_R16Ast__ast_callb_t(v_0, _fx_g21Ast_typecheck__None8_, _fx_g21Ast_typecheck__None7_, &callb_0);
   int tag_0 = FX_REC_VARIANT_TAG(t_0);
   if (tag_0 == 24) {
      _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_0 = &t_0->u.TypApp;
      if (vcase_0->t0 == 0) {
         if (vcase_0->t1.m == 0) {
            *have_typ_vars_0 = true; FX_COPY_PTR(t_0, &res_0); goto _fx_endmatch_0;
         }
      }
   }
   if (tag_0 == 24) {
      if (t_0->u.TypApp.t0 == 0) {
         FX_COPY_PTR(t_0, &res_0); goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 1) {
      FX_COPY_PTR(t_0->u.TypVar->data, &v_1);
      if ((v_1 != 0) + 1 == 1) {
         *have_typ_vars_0 = true; FX_COPY_PTR(t_0, &res_0); goto _fx_endmatch_0;
      }
   }
   FX_CALL(_fx_M3AstFM8walk_typN10Ast__typ_t2N10Ast__typ_tRM11ast_callb_t(t_0, &callb_0, &res_0, 0), _fx_catch_0);

_fx_catch_0: ;

_fx_endmatch_0: ;
   FX_CHECK_EXN(_fx_cleanup);
   *fx_result = !*have_typ_vars_0;

_fx_cleanup: ;
   FX_FREE_REF_SIMPLE(&have_typ_vars_ref_0);
   FX_FREE_FP(&is_real_typ__0);
   if (v_0) {
      _fx_free_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(&v_0);
   }
   _fx_free_R16Ast__ast_callb_t(&callb_0);
   if (res_0) {
      _fx_free_N10Ast__typ_t(&res_0);
   }
   if (v_1) {
      _fx_free_Nt6option1N10Ast__typ_t(&v_1);
   }
   return fx_status;
}

static int _fx_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R16Ast__ast_callb_t* callb_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_Nt6option1N10Ast__typ_t v_0 = 0;
   int fx_status = 0;
   _fx_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t*)fx_fv;
   bool* have_typ_vars_0 = &cv_0->t0->data;
   int tag_0 = FX_REC_VARIANT_TAG(t_0);
   if (tag_0 == 24) {
      _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_0 = &t_0->u.TypApp;
      if (vcase_0->t0 == 0) {
         if (vcase_0->t1.m == 0) {
            *have_typ_vars_0 = true; FX_COPY_PTR(t_0, fx_result); goto _fx_endmatch_0;
         }
      }
   }
   if (tag_0 == 24) {
      if (t_0->u.TypApp.t0 == 0) {
         FX_COPY_PTR(t_0, fx_result); goto _fx_endmatch_0;
      }
   }
   if (tag_0 == 1) {
      FX_COPY_PTR(t_0->u.TypVar->data, &v_0);
      if ((v_0 != 0) + 1 == 1) {
         *have_typ_vars_0 = true; FX_COPY_PTR(t_0, fx_result); goto _fx_endmatch_0;
      }
   }
   FX_CALL(_fx_M3AstFM8walk_typN10Ast__typ_t2N10Ast__typ_tRM11ast_callb_t(t_0, callb_0, fx_result, 0), _fx_catch_0);

_fx_catch_0: ;

_fx_endmatch_0: ;
   if (v_0) {
      _fx_free_Nt6option1N10Ast__typ_t(&v_0);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t1rB(
   struct _fx_rB_data_t* arg0,
   struct _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t,
      _fx_free_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t,
      _fx_M13Ast_typecheckFM12is_real_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t);
   FX_COPY_PTR(arg0, &fcv->t0);
   return 0;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM22report_not_found_typedE4R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_LN16Ast__env_entry_t_data_t* possible_matches_0,
   struct _fx_R10Ast__loc_t* loc_0,
   fx_exn_t* fx_result,
   void* fx_fv)
{
   fx_str_t nstr_0 = {0};
   _fx_LS strs_0 = 0;
   fx_str_t candidates_msg_0 = {0};
   fx_str_t v_0 = {0};
   fx_str_t v_1 = {0};
   int fx_status = 0;
   FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n_0, &nstr_0, 0), _fx_cleanup);
   _fx_LS lstend_0 = 0;
   _fx_LN16Ast__env_entry_t lst_0 = possible_matches_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N14Ast__id_info_t info_0 = {0};
      _fx_N10Ast__typ_t tj_0 = 0;
      fx_str_t v_2 = {0};
      fx_str_t v_3 = {0};
      fx_str_t concat_str_0 = {0};
      _fx_N16Ast__env_entry_t e_0 = lst_0->hd;
      int tag_0 = FX_REC_VARIANT_TAG(e_0);
      _fx_R9Ast__id_t n_1;
      if (tag_0 == 1) {
         n_1 = e_0->u.EnvId;
      }
      else if (tag_0 == 2) {
         n_1 = _fx_g9Ast__noid;
      }
      else {
         FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_0);
      }
      FX_CHECK_EXN(_fx_catch_0);
      bool res_0;
      FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&n_1, &_fx_g9Ast__noid, &res_0, 0), _fx_catch_0);
      if (res_0) {
         FX_CONTINUE(_fx_catch_0);
      }
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&n_1, loc_0, &info_0, 0), _fx_catch_0);
      bool res_1;
      if (info_0.tag == 1) {
         res_1 = true;
      }
      else {
         res_1 = false;
      }
      FX_CHECK_EXN(_fx_catch_0);
      if (res_1) {
         FX_CONTINUE(_fx_catch_0);
      }
      FX_CALL(_fx_M3AstFM14get_idinfo_typN10Ast__typ_t2N14Ast__id_info_tRM5loc_t(&info_0, loc_0, &tj_0, 0), _fx_catch_0);
      _fx_R10Ast__loc_t locj_0;
      FX_CALL(_fx_M3AstFM14get_idinfo_locRM5loc_t1N14Ast__id_info_t(&info_0, &locj_0, 0), _fx_catch_0);
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(tj_0, &v_2, 0), _fx_catch_0);
      FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(&locj_0, &v_3, 0), _fx_catch_0);
      fx_str_t slit_0 = FX_MAKE_STR("\'");
      fx_str_t slit_1 = FX_MAKE_STR(": ");
      fx_str_t slit_2 = FX_MAKE_STR("\' defined at ");
      {
         const fx_str_t strs_1[] = { slit_0, nstr_0, slit_1, v_2, slit_2, v_3 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_1, 6, &concat_str_0), _fx_catch_0);
      }
      _fx_LS node_0 = 0;
      FX_CALL(_fx_cons_LS(&concat_str_0, 0, false, &node_0), _fx_catch_0);
      FX_LIST_APPEND(strs_0, lstend_0, node_0);

   _fx_catch_0: ;
      FX_FREE_STR(&concat_str_0);
      FX_FREE_STR(&v_3);
      FX_FREE_STR(&v_2);
      if (tj_0) {
         _fx_free_N10Ast__typ_t(&tj_0);
      }
      _fx_free_N14Ast__id_info_t(&info_0);
      FX_CHECK_CONTINUE();
      FX_CHECK_EXN(_fx_cleanup);
   }
   if (strs_0 == 0) {
      fx_str_t slit_3 = FX_MAKE_STR(""); fx_copy_str(&slit_3, &candidates_msg_0);
   }
   else {
      fx_str_t slit_4 =
         FX_MAKE_STR("\n"
            U"Candidates:\n"
            U"\t");
      fx_str_t slit_5 = FX_MAKE_STR("\n");
      fx_str_t slit_6 =
         FX_MAKE_STR(",\n"
            U"\t");
      FX_CALL(_fx_F12join_embraceS4SSSLS(&slit_4, &slit_5, &slit_6, strs_0, &candidates_msg_0, 0), _fx_cleanup);
   }
   FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t_0, &v_0, 0), _fx_cleanup);
   fx_str_t slit_7 = FX_MAKE_STR("the appropriate match for \'");
   fx_str_t slit_8 = FX_MAKE_STR("\' of type \'");
   fx_str_t slit_9 = FX_MAKE_STR("\' is not found.");
   {
      const fx_str_t strs_2[] = { slit_7, nstr_0, slit_8, v_0, slit_9, candidates_msg_0 };
      FX_CALL(fx_strjoin(0, 0, 0, strs_2, 6, &v_1), _fx_cleanup);
   }
   FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_1, fx_result, 0), _fx_cleanup);

_fx_cleanup: ;
   FX_FREE_STR(&nstr_0);
   if (strs_0) {
      _fx_free_LS(&strs_0);
   }
   FX_FREE_STR(&candidates_msg_0);
   FX_FREE_STR(&v_0);
   FX_FREE_STR(&v_1);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM10find_firstNt6option1N10Ast__typ_t6R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env0_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t* pred_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LN16Ast__env_entry_t e_all_0 = 0;
   _fx_LN16Ast__env_entry_t e_all_1 = 0;
   _fx_N16Ast__env_entry_t v_0 = 0;
   _fx_Nt6option1N10Ast__typ_t result_0 = 0;
   _fx_LN16Ast__env_entry_t elist_0 = 0;
   fx_str_t n_path_0 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(n_0, env_0,
         &e_all_0, 0), _fx_cleanup);
   bool t_0;
   if (e_all_0 == 0) {
      FX_CALL(_fx_M3AstFM12is_unique_idB1RM4id_t(n_0, &t_0, 0), _fx_cleanup);
   }
   else {
      t_0 = false;
   }
   if (t_0) {
      FX_CALL(_fx_M3AstFM5EnvIdN16Ast__env_entry_t1RM4id_t(n_0, &v_0), _fx_cleanup);
      FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_0, 0, true, &e_all_1), _fx_cleanup);
   }
   else {
      FX_COPY_PTR(e_all_0, &e_all_1);
   }
   if (e_all_1 != 0) {
      FX_COPY_PTR(e_all_1, &elist_0);
      for (;;) {
         _fx_LN16Ast__env_entry_t elist_1 = 0;
         FX_COPY_PTR(elist_0, &elist_1);
         if (elist_1 != 0) {
            _fx_Nt6option1N10Ast__typ_t v_1 = 0;
            FX_CALL(pred_0->fp(elist_1->hd, &v_1, pred_0->fcv), _fx_catch_1);
            if ((v_1 != 0) + 1 == 1) {
               _fx_LN16Ast__env_entry_t* rest_0 = &elist_1->tl;
               _fx_free_LN16Ast__env_entry_t(&elist_0);
               FX_COPY_PTR(*rest_0, &elist_0);
            }
            else {
               _fx_free_Nt6option1N10Ast__typ_t(&result_0); FX_COPY_PTR(v_1, &result_0); FX_BREAK(_fx_catch_0);  _fx_catch_0: ;
            }
            FX_CHECK_EXN(_fx_catch_1);

         _fx_catch_1: ;
            if (v_1) {
               _fx_free_Nt6option1N10Ast__typ_t(&v_1);
            }
         }
         else {
            _fx_free_Nt6option1N10Ast__typ_t(&result_0);
            FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, &result_0);
            FX_BREAK(_fx_catch_2);

         _fx_catch_2: ;
         }
         FX_CHECK_EXN(_fx_catch_3);

      _fx_catch_3: ;
         if (elist_1) {
            _fx_free_LN16Ast__env_entry_t(&elist_1);
         }
         FX_CHECK_BREAK();
         FX_CHECK_EXN(_fx_cleanup);
      }
      FX_COPY_PTR(result_0, fx_result);
   }
   else {
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n_0, &n_path_0, 0), _fx_cleanup);
      FX_CALL(
         _fx_M13Ast_typecheckFM11search_pathNt6option1N10Ast__typ_t8SiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPNt6option1N10Ast__typ_t1N16Ast__env_entry_tLN12Ast__scope_t(
            &n_path_0, FX_STR_LENGTH(n_path_0) - 1, env_0, loc_0, curr_m_idx_0, env0_0, pred_0, sc_0, fx_result, 0),
         _fx_cleanup);
   }

_fx_cleanup: ;
   if (e_all_0) {
      _fx_free_LN16Ast__env_entry_t(&e_all_0);
   }
   if (e_all_1) {
      _fx_free_LN16Ast__env_entry_t(&e_all_1);
   }
   if (v_0) {
      _fx_free_N16Ast__env_entry_t(&v_0);
   }
   if (result_0) {
      _fx_free_Nt6option1N10Ast__typ_t(&result_0);
   }
   if (elist_0) {
      _fx_free_LN16Ast__env_entry_t(&elist_0);
   }
   FX_FREE_STR(&n_path_0);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM11search_pathNt6option1N10Ast__typ_t8SiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPNt6option1N10Ast__typ_t1N16Ast__env_entry_tLN12Ast__scope_t(
   fx_str_t* n_path_0,
   int_ dot_pos_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ curr_m_idx_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env0_0,
   struct _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t* pred_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_Nt6option1N10Ast__typ_t result_0 = 0;
   fx_str_t n_path_1 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   fx_copy_str(n_path_0, &n_path_1);
   int_ dot_pos_1 = dot_pos_0;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &env_1);
   _fx_R10Ast__loc_t loc_1 = *loc_0;
   for (;;) {
      fx_str_t n_path_2 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
      fx_str_t v_0 = {0};
      _fx_LN16Ast__env_entry_t v_1 = 0;
      fx_copy_str(&n_path_1, &n_path_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &env_2);
      _fx_R10Ast__loc_t loc_2 = loc_1;
      int_ dot_pos_2 = _fx_M6StringFM5rfindi3SCi(&n_path_2, (char_)46, dot_pos_1, 0);
      if (dot_pos_2 < 0) {
         _fx_free_Nt6option1N10Ast__typ_t(&result_0);
         FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, &result_0);
         FX_BREAK(_fx_catch_3);
      }
      else {
         FX_CALL(fx_substr(&n_path_2, 0, dot_pos_2, 1, 1, &v_0), _fx_catch_3);
         _fx_R9Ast__id_t v_2;
         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_0, &v_2, 0), _fx_catch_3);
         FX_CALL(
            _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_2,
               &env_2, &v_1, 0), _fx_catch_3);
         if (v_1 != 0) {
            _fx_N16Ast__env_entry_t v_3 = v_1->hd;
            if (FX_REC_VARIANT_TAG(v_3) == 1) {
               _fx_N14Ast__id_info_t v_4 = {0};
               FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&v_3->u.EnvId, &loc_2, &v_4, 0), _fx_catch_2);
               if (v_4.tag == 8) {
                  _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
                  fx_str_t v_5 = {0};
                  _fx_Nt6option1N10Ast__typ_t result_1 = 0;
                  int_ m_idx_0 = v_4.u.IdModule;
                  if (m_idx_0 == curr_m_idx_0) {
                     _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env0_0, &env_3);
                  }
                  else {
                     FX_CALL(_fx_M3AstFM14get_module_envRt6Map__t2RM4id_tLN16Ast__env_entry_t1i(m_idx_0, &env_3, 0),
                        _fx_catch_0);
                  }
                  FX_CALL(fx_substr(&n_path_2, dot_pos_2 + 1, 0, 1, 2, &v_5), _fx_catch_0);
                  _fx_R9Ast__id_t v_6;
                  FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_5, &v_6, 0), _fx_catch_0);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM10find_firstNt6option1N10Ast__typ_t6R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t(
                        &v_6, &env_3, env0_0, sc_0, &loc_2, pred_0, &result_1, 0), _fx_catch_0);
                  _fx_free_Nt6option1N10Ast__typ_t(&result_0);
                  FX_COPY_PTR(result_1, &result_0);
                  FX_BREAK(_fx_catch_0);

               _fx_catch_0: ;
                  if (result_1) {
                     _fx_free_Nt6option1N10Ast__typ_t(&result_1);
                  }
                  FX_FREE_STR(&v_5);
                  _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
               }
               else {
                  _fx_free_Nt6option1N10Ast__typ_t(&result_0);
                  FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, &result_0);
                  FX_BREAK(_fx_catch_1);

               _fx_catch_1: ;
               }
               FX_CHECK_EXN(_fx_catch_2);

            _fx_catch_2: ;
               _fx_free_N14Ast__id_info_t(&v_4);
               goto _fx_endmatch_0;
            }
         }
         FX_FREE_STR(&n_path_1);
         fx_copy_str(&n_path_2, &n_path_1);
         dot_pos_1 = dot_pos_2 - 1;
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &env_1);
         loc_1 = loc_2;

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_3);
      }

   _fx_catch_3: ;
      if (v_1) {
         _fx_free_LN16Ast__env_entry_t(&v_1);
      }
      FX_FREE_STR(&v_0);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
      FX_FREE_STR(&n_path_2);
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(result_0, fx_result);

_fx_cleanup: ;
   if (result_0) {
      _fx_free_Nt6option1N10Ast__typ_t(&result_0);
   }
   FX_FREE_STR(&n_path_1);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM10find_firstNt6option1T2R9Ast__id_tN10Ast__typ_t6R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env0_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_FPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t* pred_0,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv)
{
   _fx_LN16Ast__env_entry_t e_all_0 = 0;
   _fx_LN16Ast__env_entry_t e_all_1 = 0;
   _fx_N16Ast__env_entry_t v_0 = 0;
   _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t result_0 = {0};
   _fx_LN16Ast__env_entry_t elist_0 = 0;
   fx_str_t n_path_0 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(n_0, env_0,
         &e_all_0, 0), _fx_cleanup);
   bool t_0;
   if (e_all_0 == 0) {
      FX_CALL(_fx_M3AstFM12is_unique_idB1RM4id_t(n_0, &t_0, 0), _fx_cleanup);
   }
   else {
      t_0 = false;
   }
   if (t_0) {
      FX_CALL(_fx_M3AstFM5EnvIdN16Ast__env_entry_t1RM4id_t(n_0, &v_0), _fx_cleanup);
      FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_0, 0, true, &e_all_1), _fx_cleanup);
   }
   else {
      FX_COPY_PTR(e_all_0, &e_all_1);
   }
   if (e_all_1 != 0) {
      FX_COPY_PTR(e_all_1, &elist_0);
      for (;;) {
         _fx_LN16Ast__env_entry_t elist_1 = 0;
         FX_COPY_PTR(elist_0, &elist_1);
         if (elist_1 != 0) {
            _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t v_1 = {0};
            FX_CALL(pred_0->fp(elist_1->hd, &v_1, pred_0->fcv), _fx_catch_1);
            if (v_1.tag == 1) {
               _fx_LN16Ast__env_entry_t* rest_0 = &elist_1->tl;
               _fx_free_LN16Ast__env_entry_t(&elist_0);
               FX_COPY_PTR(*rest_0, &elist_0);
            }
            else {
               _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0);
               _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_1, &result_0);
               FX_BREAK(_fx_catch_0);

            _fx_catch_0: ;
            }
            FX_CHECK_EXN(_fx_catch_1);

         _fx_catch_1: ;
            _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_1);
         }
         else {
            _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0);
            _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, &result_0);
            FX_BREAK(_fx_catch_2);

         _fx_catch_2: ;
         }
         FX_CHECK_EXN(_fx_catch_3);

      _fx_catch_3: ;
         if (elist_1) {
            _fx_free_LN16Ast__env_entry_t(&elist_1);
         }
         FX_CHECK_BREAK();
         FX_CHECK_EXN(_fx_cleanup);
      }
      _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0, fx_result);
   }
   else {
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n_0, &n_path_0, 0), _fx_cleanup);
      FX_CALL(
         _fx_M13Ast_typecheckFM11search_pathNt6option1T2R9Ast__id_tN10Ast__typ_t8SiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_tLN12Ast__scope_t(
            &n_path_0, FX_STR_LENGTH(n_path_0) - 1, env_0, loc_0, curr_m_idx_0, env0_0, pred_0, sc_0, fx_result, 0),
         _fx_cleanup);
   }

_fx_cleanup: ;
   if (e_all_0) {
      _fx_free_LN16Ast__env_entry_t(&e_all_0);
   }
   if (e_all_1) {
      _fx_free_LN16Ast__env_entry_t(&e_all_1);
   }
   if (v_0) {
      _fx_free_N16Ast__env_entry_t(&v_0);
   }
   _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0);
   if (elist_0) {
      _fx_free_LN16Ast__env_entry_t(&elist_0);
   }
   FX_FREE_STR(&n_path_0);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM11search_pathNt6option1T2R9Ast__id_tN10Ast__typ_t8SiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_tLN12Ast__scope_t(
   fx_str_t* n_path_0,
   int_ dot_pos_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ curr_m_idx_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env0_0,
   struct _fx_FPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t* pred_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv)
{
   _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t result_0 = {0};
   fx_str_t n_path_1 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   fx_copy_str(n_path_0, &n_path_1);
   int_ dot_pos_1 = dot_pos_0;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &env_1);
   _fx_R10Ast__loc_t loc_1 = *loc_0;
   for (;;) {
      fx_str_t n_path_2 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
      fx_str_t v_0 = {0};
      _fx_LN16Ast__env_entry_t v_1 = 0;
      fx_copy_str(&n_path_1, &n_path_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &env_2);
      _fx_R10Ast__loc_t loc_2 = loc_1;
      int_ dot_pos_2 = _fx_M6StringFM5rfindi3SCi(&n_path_2, (char_)46, dot_pos_1, 0);
      if (dot_pos_2 < 0) {
         _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0);
         _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, &result_0);
         FX_BREAK(_fx_catch_3);
      }
      else {
         FX_CALL(fx_substr(&n_path_2, 0, dot_pos_2, 1, 1, &v_0), _fx_catch_3);
         _fx_R9Ast__id_t v_2;
         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_0, &v_2, 0), _fx_catch_3);
         FX_CALL(
            _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_2,
               &env_2, &v_1, 0), _fx_catch_3);
         if (v_1 != 0) {
            _fx_N16Ast__env_entry_t v_3 = v_1->hd;
            if (FX_REC_VARIANT_TAG(v_3) == 1) {
               _fx_N14Ast__id_info_t v_4 = {0};
               FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&v_3->u.EnvId, &loc_2, &v_4, 0), _fx_catch_2);
               if (v_4.tag == 8) {
                  _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
                  fx_str_t v_5 = {0};
                  _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t result_1 = {0};
                  int_ m_idx_0 = v_4.u.IdModule;
                  if (m_idx_0 == curr_m_idx_0) {
                     _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env0_0, &env_3);
                  }
                  else {
                     FX_CALL(_fx_M3AstFM14get_module_envRt6Map__t2RM4id_tLN16Ast__env_entry_t1i(m_idx_0, &env_3, 0),
                        _fx_catch_0);
                  }
                  FX_CALL(fx_substr(&n_path_2, dot_pos_2 + 1, 0, 1, 2, &v_5), _fx_catch_0);
                  _fx_R9Ast__id_t v_6;
                  FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_5, &v_6, 0), _fx_catch_0);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM10find_firstNt6option1T2R9Ast__id_tN10Ast__typ_t6R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t(
                        &v_6, &env_3, env0_0, sc_0, &loc_2, pred_0, &result_1, 0), _fx_catch_0);
                  _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0);
                  _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_1, &result_0);
                  FX_BREAK(_fx_catch_0);

               _fx_catch_0: ;
                  _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_1);
                  FX_FREE_STR(&v_5);
                  _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
               }
               else {
                  _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0);
                  _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, &result_0);
                  FX_BREAK(_fx_catch_1);

               _fx_catch_1: ;
               }
               FX_CHECK_EXN(_fx_catch_2);

            _fx_catch_2: ;
               _fx_free_N14Ast__id_info_t(&v_4);
               goto _fx_endmatch_0;
            }
         }
         FX_FREE_STR(&n_path_1);
         fx_copy_str(&n_path_2, &n_path_1);
         dot_pos_1 = dot_pos_2 - 1;
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &env_1);
         loc_1 = loc_2;

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_3);
      }

   _fx_catch_3: ;
      if (v_1) {
         _fx_free_LN16Ast__env_entry_t(&v_1);
      }
      FX_FREE_STR(&v_0);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
      FX_FREE_STR(&n_path_2);
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0, fx_result);

_fx_cleanup: ;
   _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&result_0);
   FX_FREE_STR(&n_path_1);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM13lookup_id_optT2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_rLN16Ast__env_entry_t possible_matches_ref_0 = 0;
   _fx_FPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t __lambda___0 = {0};
   _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t nt_opt_0 = {0};
   int fx_status = 0;
   FX_CALL(_fx_make_rLN16Ast__env_entry_t(0, &possible_matches_ref_0), _fx_cleanup);
   _fx_M13Ast_typecheckFM7make_fpFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tR9Ast__id_trLN16Ast__env_entry_tLN12Ast__scope_tN10Ast__typ_t(
      env_0, loc_0, n_0, possible_matches_ref_0, sc_0, t_0, &__lambda___0);
   FX_CALL(
      _fx_M13Ast_typecheckFM10find_firstNt6option1T2R9Ast__id_tN10Ast__typ_t6R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t(
         n_0, env_0, env_0, sc_0, loc_0, &__lambda___0, &nt_opt_0, 0), _fx_cleanup);
   _fx_make_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t(&nt_opt_0, possible_matches_ref_0->data, fx_result);

_fx_cleanup: ;
   if (possible_matches_ref_0) {
      _fx_free_rLN16Ast__env_entry_t(&possible_matches_ref_0);
   }
   FX_FREE_FP(&__lambda___0);
   _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&nt_opt_0);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t(
   struct _fx_N16Ast__env_entry_t_data_t* e_0,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t_cldata_t*)fx_fv;
   _fx_R10Ast__loc_t* loc_0 = &cv_0->t1;
   _fx_LN12Ast__scope_t sc_0 = cv_0->t4;
   _fx_N10Ast__typ_t t_0 = cv_0->t5;
   _fx_LN16Ast__env_entry_t* possible_matches_0 = &cv_0->t3->data;
   int tag_0 = FX_REC_VARIANT_TAG(e_0);
   if (tag_0 == 1) {
      if (e_0->u.EnvId.m == 0) {
         _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, fx_result); goto _fx_endmatch_5;
      }
   }
   if (tag_0 == 1) {
      _fx_LN16Ast__env_entry_t v_0 = 0;
      _fx_N14Ast__id_info_t v_1 = {0};
      _fx_R9Ast__id_t* i_0 = &e_0->u.EnvId;
      FX_CALL(_fx_cons_LN16Ast__env_entry_t(e_0, *possible_matches_0, true, &v_0), _fx_catch_18);
      _fx_free_LN16Ast__env_entry_t(possible_matches_0);
      FX_COPY_PTR(v_0, possible_matches_0);
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(i_0, loc_0, &v_1, 0), _fx_catch_18);
      int tag_1 = v_1.tag;
      if (tag_1 == 2) {
         fx_str_t v_2 = {0};
         fx_str_t v_3 = {0};
         fx_str_t v_4 = {0};
         fx_str_t v_5 = {0};
         fx_exn_t v_6 = {0};
         _fx_T2R9Ast__id_tN10Ast__typ_t v_7 = {0};
         _fx_N10Ast__typ_t dv_typ_0 = v_1.u.IdDVal.dv_typ;
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&cv_0->t2, &v_2, 0), _fx_catch_0);
         FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t_0, &v_3, 0), _fx_catch_0);
         FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(dv_typ_0, &v_4, 0), _fx_catch_0);
         fx_str_t slit_0 = FX_MAKE_STR("incorrect type of value \'");
         fx_str_t slit_1 = FX_MAKE_STR("\': expected=\'");
         fx_str_t slit_2 = FX_MAKE_STR("\', actual=\'");
         fx_str_t slit_3 = FX_MAKE_STR("\'");
         {
            const fx_str_t strs_0[] = { slit_0, v_2, slit_1, v_3, slit_2, v_4, slit_3 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_0, 7, &v_5), _fx_catch_0);
         }
         bool v_8;
         FX_CALL(
            _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(dv_typ_0, t_0, loc_0, true, &v_8, 0),
            _fx_catch_0);
         if (!v_8) {
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_5, &v_6, 0), _fx_catch_0); FX_THROW(&v_6, false, _fx_catch_0);
         }
         _fx_make_T2R9Ast__id_tN10Ast__typ_t(i_0, t_0, &v_7);
         _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_7, fx_result);

      _fx_catch_0: ;
         _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_7);
         fx_free_exn(&v_6);
         FX_FREE_STR(&v_5);
         FX_FREE_STR(&v_4);
         FX_FREE_STR(&v_3);
         FX_FREE_STR(&v_2);
         goto _fx_endmatch_4;
      }
      if (tag_1 == 3) {
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t df_env_0 = {0};
         _fx_rLR9Ast__id_t df_templ_inst_0 = 0;
         _fx_N10Ast__typ_t df_typ_0 = 0;
         _fx_LR9Ast__id_t df_templ_args_0 = 0;
         _fx_N10Ast__typ_t v_9 = 0;
         _fx_N10Ast__typ_t t_1 = 0;
         _fx_T2R9Ast__id_tN10Ast__typ_t v_10 = {0};
         _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_11 = {0};
         _fx_N10Ast__typ_t ftyp_0 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_0 = {0};
         _fx_T2R9Ast__id_tN10Ast__typ_t v_12 = {0};
         _fx_LR9Ast__id_t v_13 = 0;
         _fx_rR13Ast__deffun_t df_0 = v_1.u.IdFun;
         _fx_R13Ast__deffun_t* v_14 = &df_0->data;
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_14->df_env, &df_env_0);
         FX_COPY_PTR(v_14->df_templ_inst, &df_templ_inst_0);
         _fx_R16Ast__fun_flags_t df_flags_0 = v_14->df_flags;
         FX_COPY_PTR(v_14->df_typ, &df_typ_0);
         FX_COPY_PTR(v_14->df_templ_args, &df_templ_args_0);
         _fx_R9Ast__id_t df_name_0 = v_14->df_name;
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t_0, &v_9, 0), _fx_catch_13);
         if (df_flags_0.fun_flag_have_keywords == true) {
            if (FX_REC_VARIANT_TAG(v_9) == 14) {
               _fx_LN10Ast__typ_t argtyps_0 = 0;
               _fx_N10Ast__typ_t result_0 = 0;
               _fx_LN10Ast__typ_t __pat___0 = 0;
               _fx_N10Ast__typ_t v_15 = 0;
               _fx_N10Ast__typ_t v_16 = 0;
               _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_17 = {0};
               _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_0 = &v_9->u.TypFun;
               _fx_LN10Ast__typ_t argtyps_1 = vcase_0->t0;
               if (argtyps_1 != 0) {
                  FX_COPY_PTR(argtyps_1, &__pat___0);
                  for (;;) {
                     _fx_LN10Ast__typ_t __pat___1 = 0;
                     FX_COPY_PTR(__pat___0, &__pat___1);
                     if (__pat___1 != 0) {
                        if (__pat___1->tl == 0) {
                           _fx_N10Ast__typ_t result_1 = 0;
                           FX_COPY_PTR(__pat___1->hd, &result_1);
                           _fx_free_N10Ast__typ_t(&result_0);
                           FX_COPY_PTR(result_1, &result_0);
                           FX_BREAK(_fx_catch_1);

                        _fx_catch_1: ;
                           if (result_1) {
                              _fx_free_N10Ast__typ_t(&result_1);
                           }
                           goto _fx_endmatch_0;
                        }
                     }
                     if (__pat___1 != 0) {
                        _fx_LN10Ast__typ_t* rest_0 = &__pat___1->tl;
                        _fx_free_LN10Ast__typ_t(&__pat___0);
                        FX_COPY_PTR(*rest_0, &__pat___0);
                        goto _fx_endmatch_0;
                     }
                     FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_2);

                  _fx_endmatch_0: ;
                     FX_CHECK_EXN(_fx_catch_2);

                  _fx_catch_2: ;
                     if (__pat___1) {
                        _fx_free_LN10Ast__typ_t(&__pat___1);
                     }
                     FX_CHECK_BREAK();
                     FX_CHECK_EXN(_fx_catch_6);
                  }
                  FX_COPY_PTR(result_0, &v_15);
                  FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(v_15, &v_16, 0), _fx_catch_6);
                  bool res_0;
                  if (FX_REC_VARIANT_TAG(v_16) == 20) {
                     _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_16->u.TypRecord->data, &v_17);
                     if (v_17.t1 == false) {
                        res_0 = true; goto _fx_endmatch_1;
                     }
                  }
                  res_0 = false;

               _fx_endmatch_1: ;
                  FX_CHECK_EXN(_fx_catch_6);
                  if (res_0) {
                     FX_COPY_PTR(argtyps_1, &argtyps_0); goto _fx_endmatch_2;
                  }
               }
               _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_18 = {0};
               _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_19 = 0;
               _fx_N10Ast__typ_t v_20 = 0;
               _fx_LN10Ast__typ_t v_21 = 0;
               _fx_make_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(0, false, &v_18);
               FX_CALL(_fx_make_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_18, &v_19), _fx_catch_5);
               FX_CALL(_fx_M3AstFM9TypRecordN10Ast__typ_t1rT2LT4RM11val_flags_tRM4id_tN10Ast__typ_tN10Ast__exp_tB(v_19, &v_20),
                  _fx_catch_5);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_20, 0, true, &v_21), _fx_catch_5);
               if (argtyps_1 == 0) {
                  FX_COPY_PTR(v_21, &argtyps_0);
               }
               else if (v_21 == 0) {
                  FX_COPY_PTR(argtyps_1, &argtyps_0);
               }
               else {
                  _fx_LN10Ast__typ_t v_22 = 0;
                  _fx_LN10Ast__typ_t argtyps_2 = 0;
                  _fx_LN10Ast__typ_t lstend_0 = 0;
                  FX_COPY_PTR(argtyps_1, &argtyps_2);
                  _fx_LN10Ast__typ_t lst_0 = argtyps_2;
                  for (; lst_0; lst_0 = lst_0->tl) {
                     _fx_N10Ast__typ_t x_0 = lst_0->hd;
                     _fx_LN10Ast__typ_t node_0 = 0;
                     FX_CALL(_fx_cons_LN10Ast__typ_t(x_0, 0, false, &node_0), _fx_catch_3);
                     FX_LIST_APPEND(v_22, lstend_0, node_0);

                  _fx_catch_3: ;
                     FX_CHECK_EXN(_fx_catch_4);
                  }
                  _fx_M13Ast_typecheckFM5link2LN10Ast__typ_t2LN10Ast__typ_tLN10Ast__typ_t(v_22, v_21, &argtyps_0, 0);

               _fx_catch_4: ;
                  if (argtyps_2) {
                     _fx_free_LN10Ast__typ_t(&argtyps_2);
                  }
                  if (v_22) {
                     _fx_free_LN10Ast__typ_t(&v_22);
                  }
               }
               FX_CHECK_EXN(_fx_catch_5);

            _fx_catch_5: ;
               if (v_21) {
                  _fx_free_LN10Ast__typ_t(&v_21);
               }
               if (v_20) {
                  _fx_free_N10Ast__typ_t(&v_20);
               }
               if (v_19) {
                  _fx_free_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_19);
               }
               _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_18);

            _fx_endmatch_2: ;
               FX_CHECK_EXN(_fx_catch_6);
               FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(argtyps_0, vcase_0->t1, &t_1), _fx_catch_6);

            _fx_catch_6: ;
               _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_17);
               if (v_16) {
                  _fx_free_N10Ast__typ_t(&v_16);
               }
               if (v_15) {
                  _fx_free_N10Ast__typ_t(&v_15);
               }
               if (__pat___0) {
                  _fx_free_LN10Ast__typ_t(&__pat___0);
               }
               if (result_0) {
                  _fx_free_N10Ast__typ_t(&result_0);
               }
               if (argtyps_0) {
                  _fx_free_LN10Ast__typ_t(&argtyps_0);
               }
               goto _fx_endmatch_3;
            }
         }
         FX_COPY_PTR(t_0, &t_1);

      _fx_endmatch_3: ;
         FX_CHECK_EXN(_fx_catch_13);
         if (df_templ_args_0 == 0) {
            bool v_23;
            FX_CALL(
               _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(df_typ_0, t_1, loc_0, true, &v_23,
                  0), _fx_catch_13);
            if (v_23) {
               _fx_make_T2R9Ast__id_tN10Ast__typ_t(i_0, t_1, &v_10);
               _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_10, fx_result);
            }
            else {
               _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, fx_result);
            }
         }
         else {
            FX_CALL(
               _fx_M13Ast_typecheckFM20preprocess_templ_typT2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5LR9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  df_templ_args_0, df_typ_0, &df_env_0, sc_0, loc_0, &v_11, 0), _fx_catch_13);
            FX_COPY_PTR(v_11.t0, &ftyp_0);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_11.t1, &env1_0);
            bool v_24;
            FX_CALL(
               _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(ftyp_0, t_1, loc_0, true, &v_24,
                  0), _fx_catch_13);
            if (!v_24) {
               _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, fx_result);
            }
            else {
               bool res_1;
               FX_CALL(_fx_M3AstFM14is_constructorB1RM11fun_flags_t(&df_flags_0, &res_1, 0), _fx_catch_13);
               bool return_orig_0;
               if (!res_1) {
                  return_orig_0 = false;
               }
               else {
                  if (FX_REC_VARIANT_TAG(ftyp_0) == 14) {
                     _fx_N10Ast__typ_t res_2 = 0;
                     FX_CALL(
                        _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                           ftyp_0->u.TypFun.t1, &env1_0, sc_0, loc_0, &res_2, 0), _fx_catch_7);
                     return_orig_0 = false;

                  _fx_catch_7: ;
                     if (res_2) {
                        _fx_free_N10Ast__typ_t(&res_2);
                     }
                  }
                  else {
                     bool v_25;
                     FX_CALL(_fx_M3AstFM12is_fixed_typB1N10Ast__typ_t(t_1, &v_25, 0), _fx_catch_8);
                     return_orig_0 = !v_25;

                  _fx_catch_8: ;
                  }
                  FX_CHECK_EXN(_fx_catch_13);
               }
               if (return_orig_0) {
                  _fx_make_T2R9Ast__id_tN10Ast__typ_t(&df_name_0, t_1, &v_12);
                  _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_12, fx_result);
               }
               else {
                  _fx_Nt6option1R9Ast__id_t __fold_result___0 = _fx_g21Ast_typecheck__None9_;
                  FX_COPY_PTR(df_templ_inst_0->data, &v_13);
                  _fx_LR9Ast__id_t lst_1 = v_13;
                  for (; lst_1; lst_1 = lst_1->tl) {
                     _fx_N14Ast__id_info_t v_26 = {0};
                     _fx_R9Ast__id_t* inst_0 = &lst_1->hd;
                     FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(inst_0, loc_0, &v_26, 0), _fx_catch_11);
                     bool v_27;
                     if (v_26.tag == 3) {
                        _fx_R13Ast__deffun_t v_28 = {0};
                        _fx_copy_R13Ast__deffun_t(&v_26.u.IdFun->data, &v_28);
                        FX_CALL(
                           _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(v_28.df_typ, t_1,
                              loc_0, true, &v_27, 0), _fx_catch_9);

                     _fx_catch_9: ;
                        _fx_free_R13Ast__deffun_t(&v_28);
                     }
                     else {
                        fx_str_t v_29 = {0};
                        fx_str_t v_30 = {0};
                        fx_str_t v_31 = {0};
                        fx_exn_t v_32 = {0};
                        FX_CALL(_fx_M3AstFM6stringS1RM4id_t(inst_0, &v_29, 0), _fx_catch_10);
                        FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&df_name_0, &v_30, 0), _fx_catch_10);
                        fx_str_t slit_4 = FX_MAKE_STR("invalid (non-function) instance ");
                        fx_str_t slit_5 = FX_MAKE_STR(" of template function ");
                        {
                           const fx_str_t strs_1[] = { slit_4, v_29, slit_5, v_30 };
                           FX_CALL(fx_strjoin(0, 0, 0, strs_1, 4, &v_31), _fx_catch_10);
                        }
                        FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_31, &v_32, 0), _fx_catch_10);
                        FX_THROW(&v_32, false, _fx_catch_10);

                     _fx_catch_10: ;
                        fx_free_exn(&v_32);
                        FX_FREE_STR(&v_31);
                        FX_FREE_STR(&v_30);
                        FX_FREE_STR(&v_29);
                     }
                     FX_CHECK_EXN(_fx_catch_11);
                     if (v_27) {
                        _fx_Nt6option1R9Ast__id_t v_33;
                        _fx_M13Ast_typecheckFM4SomeNt6option1R9Ast__id_t1R9Ast__id_t(inst_0, &v_33);
                        __fold_result___0 = v_33;
                        FX_BREAK(_fx_catch_11);
                     }

                  _fx_catch_11: ;
                     _fx_free_N14Ast__id_info_t(&v_26);
                     FX_CHECK_BREAK();
                     FX_CHECK_EXN(_fx_catch_13);
                  }
                  _fx_Nt6option1R9Ast__id_t inst_name_opt_0 = __fold_result___0;
                  if (inst_name_opt_0.tag == 2) {
                     _fx_T2R9Ast__id_tN10Ast__typ_t v_34 = {0};
                     _fx_make_T2R9Ast__id_tN10Ast__typ_t(&inst_name_opt_0.u.Some, t_1, &v_34);
                     _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_34,
                        fx_result);
                     _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_34);
                  }
                  else {
                     _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t inst_env_0 = {0};
                     _fx_rR13Ast__deffun_t v_35 = 0;
                     _fx_N10Ast__typ_t inst_typ_0 = 0;
                     fx_exn_t v_36 = {0};
                     _fx_T2R9Ast__id_tN10Ast__typ_t v_37 = {0};
                     FX_CALL(
                        _fx_M13Ast_typecheckFM14inst_merge_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
                           &cv_0->t0, &env1_0, &inst_env_0, 0), _fx_catch_12);
                     FX_CALL(
                        _fx_M13Ast_typecheckFM15instantiate_funrR13Ast__deffun_t5rR13Ast__deffun_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tB(
                           df_0, ftyp_0, &inst_env_0, loc_0, true, &v_35, 0), _fx_catch_12);
                     _fx_R13Ast__deffun_t* v_38 = &v_35->data;
                     FX_COPY_PTR(v_38->df_typ, &inst_typ_0);
                     _fx_R9Ast__id_t inst_name_0 = v_38->df_name;
                     bool v_39;
                     FX_CALL(
                        _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(inst_typ_0, t_1, loc_0,
                           true, &v_39, 0), _fx_catch_12);
                     if (!v_39) {
                        fx_str_t slit_6 = FX_MAKE_STR("inconsistent type of the instantiated function");
                        FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_6, &v_36, 0), _fx_catch_12);
                        FX_THROW(&v_36, false, _fx_catch_12);
                     }
                     _fx_make_T2R9Ast__id_tN10Ast__typ_t(&inst_name_0, t_1, &v_37);
                     _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_37,
                        fx_result);

                  _fx_catch_12: ;
                     _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_37);
                     fx_free_exn(&v_36);
                     if (inst_typ_0) {
                        _fx_free_N10Ast__typ_t(&inst_typ_0);
                     }
                     if (v_35) {
                        _fx_free_rR13Ast__deffun_t(&v_35);
                     }
                     _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&inst_env_0);
                  }
                  FX_CHECK_EXN(_fx_catch_13);
               }
            }
         }

      _fx_catch_13: ;
         FX_FREE_LIST_SIMPLE(&v_13);
         _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_12);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0);
         if (ftyp_0) {
            _fx_free_N10Ast__typ_t(&ftyp_0);
         }
         _fx_free_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_11);
         _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_10);
         if (t_1) {
            _fx_free_N10Ast__typ_t(&t_1);
         }
         if (v_9) {
            _fx_free_N10Ast__typ_t(&v_9);
         }
         FX_FREE_LIST_SIMPLE(&df_templ_args_0);
         if (df_typ_0) {
            _fx_free_N10Ast__typ_t(&df_typ_0);
         }
         if (df_templ_inst_0) {
            _fx_free_rLR9Ast__id_t(&df_templ_inst_0);
         }
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&df_env_0);
         goto _fx_endmatch_4;
      }
      if (tag_1 == 8) {
         fx_exn_t v_40 = {0};
         _fx_T2R9Ast__id_tN10Ast__typ_t v_41 = {0};
         bool v_42;
         FX_CALL(
            _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(_fx_g24Ast_typecheck__TypModule, t_0,
               loc_0, true, &v_42, 0), _fx_catch_14);
         if (!v_42) {
            fx_str_t slit_7 = FX_MAKE_STR("unexpected module name");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_7, &v_40, 0), _fx_catch_14);
            FX_THROW(&v_40, false, _fx_catch_14);
         }
         _fx_make_T2R9Ast__id_tN10Ast__typ_t(i_0, t_0, &v_41);
         _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_41, fx_result);

      _fx_catch_14: ;
         _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_41);
         fx_free_exn(&v_40);
         goto _fx_endmatch_4;
      }
      if (tag_1 == 4) {
         _fx_R13Ast__defexn_t v_43 = {0};
         _fx_N10Ast__typ_t ctyp_0 = 0;
         fx_exn_t v_44 = {0};
         _fx_T2R9Ast__id_tN10Ast__typ_t v_45 = {0};
         _fx_copy_R13Ast__defexn_t(&v_1.u.IdExn->data, &v_43);
         _fx_N10Ast__typ_t dexn_typ_0 = v_43.dexn_typ;
         if (FX_REC_VARIANT_TAG(dexn_typ_0) == 13) {
            FX_COPY_PTR(_fx_g21Ast_typecheck__TypExn, &ctyp_0);
         }
         else {
            _fx_LN10Ast__typ_t v_46 = 0;
            if (FX_REC_VARIANT_TAG(dexn_typ_0) == 17) {
               FX_COPY_PTR(dexn_typ_0->u.TypTuple, &v_46);
            }
            else {
               FX_CALL(_fx_cons_LN10Ast__typ_t(dexn_typ_0, 0, true, &v_46), _fx_catch_15);  _fx_catch_15: ;
            }
            FX_CHECK_EXN(_fx_catch_16);
            FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(v_46, _fx_g21Ast_typecheck__TypExn, &ctyp_0),
               _fx_catch_16);

         _fx_catch_16: ;
            if (v_46) {
               _fx_free_LN10Ast__typ_t(&v_46);
            }
         }
         FX_CHECK_EXN(_fx_catch_17);
         bool v_47;
         FX_CALL(
            _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(ctyp_0, t_0, loc_0, true, &v_47, 0),
            _fx_catch_17);
         if (!v_47) {
            fx_str_t slit_8 = FX_MAKE_STR("uncorrect type of exception constructor and/or its arguments");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_8, &v_44, 0), _fx_catch_17);
            FX_THROW(&v_44, false, _fx_catch_17);
         }
         _fx_make_T2R9Ast__id_tN10Ast__typ_t(i_0, t_0, &v_45);
         _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_45, fx_result);

      _fx_catch_17: ;
         _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_45);
         fx_free_exn(&v_44);
         if (ctyp_0) {
            _fx_free_N10Ast__typ_t(&ctyp_0);
         }
         _fx_free_R13Ast__defexn_t(&v_43);
         goto _fx_endmatch_4;
      }
      bool res_3;
      if (tag_1 == 1) {
         res_3 = true;
      }
      else if (tag_1 == 5) {
         res_3 = true;
      }
      else if (tag_1 == 6) {
         res_3 = true;
      }
      else if (tag_1 == 7) {
         res_3 = true;
      }
      else {
         res_3 = false;
      }
      FX_CHECK_EXN(_fx_catch_18);
      if (res_3) {
         _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, fx_result); goto _fx_endmatch_4;
      }
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_18);

   _fx_endmatch_4: ;
      FX_CHECK_EXN(_fx_catch_18);

   _fx_catch_18: ;
      _fx_free_N14Ast__id_info_t(&v_1);
      if (v_0) {
         _fx_free_LN16Ast__env_entry_t(&v_0);
      }
      goto _fx_endmatch_5;
   }
   if (tag_0 == 2) {
      _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, fx_result); goto _fx_endmatch_5;
   }
   FX_FAST_THROW(FX_EXN_NoMatchError, _fx_cleanup);

_fx_endmatch_5: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tR9Ast__id_trLN16Ast__env_entry_tLN12Ast__scope_tN10Ast__typ_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   struct _fx_R9Ast__id_t* arg2,
   struct _fx_rLN16Ast__env_entry_t_data_t* arg3,
   struct _fx_LN12Ast__scope_t_data_t* arg4,
   struct _fx_N10Ast__typ_t_data_t* arg5,
   struct _fx_FPNt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t_cldata_t,
      _fx_free_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t,
      _fx_M13Ast_typecheckFM10__lambda__Nt6option1T2R9Ast__id_tN10Ast__typ_t1N16Ast__env_entry_t);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(arg0, &fcv->t0);
   fcv->t1 = *arg1;
   fcv->t2 = *arg2;
   FX_COPY_PTR(arg3, &fcv->t3);
   FX_COPY_PTR(arg4, &fcv->t4);
   FX_COPY_PTR(arg5, &fcv->t5);
   return 0;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9lookup_idT2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv)
{
   _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t v_0 = {0};
   _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t nt_opt_0 = {0};
   _fx_LN16Ast__env_entry_t possible_matches_0 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM13lookup_id_optT2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
         n_0, t_0, env_0, sc_0, loc_0, &v_0, 0), _fx_cleanup);
   _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_0.t0, &nt_opt_0);
   FX_COPY_PTR(v_0.t1, &possible_matches_0);
   int tag_0 = nt_opt_0.tag;
   if (tag_0 == 2) {
      _fx_copy_T2R9Ast__id_tN10Ast__typ_t(&nt_opt_0.u.Some, fx_result);
   }
   else if (tag_0 == 1) {
      _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t v_1 = {0};
      FX_CALL(
         _fx_M13Ast_typecheckFM19try_autogen_symbolsNt6option1T2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
            n_0, t_0, env_0, sc_0, loc_0, &v_1, 0), _fx_catch_1);
      if (v_1.tag == 2) {
         _fx_copy_T2R9Ast__id_tN10Ast__typ_t(&v_1.u.Some, fx_result);
      }
      else {
         fx_exn_t v_2 = {0};
         FX_CALL(
            _fx_M13Ast_typecheckFM22report_not_found_typedE4R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_tR10Ast__loc_t(n_0, t_0,
               possible_matches_0, loc_0, &v_2, 0), _fx_catch_0);
         FX_THROW(&v_2, false, _fx_catch_0);

      _fx_catch_0: ;
         fx_free_exn(&v_2);
      }
      FX_CHECK_EXN(_fx_catch_1);

   _fx_catch_1: ;
      _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_1);
   }
   else {
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_cleanup);
   }

_fx_cleanup: ;
   _fx_free_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t(&v_0);
   _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&nt_opt_0);
   if (possible_matches_0) {
      _fx_free_LN16Ast__env_entry_t(&possible_matches_0);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM19try_autogen_symbolsNt6option1T2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv)
{
   fx_str_t nstr_0 = {0};
   _fx_N10Ast__typ_t v_0 = 0;
   _fx_N14Ast__id_info_t v_1 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n_0, &nstr_0, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM13deref_typ_recN10Ast__typ_t1N10Ast__typ_t(t_0, &v_0, 0), _fx_cleanup);
   fx_str_t slit_0 = FX_MAKE_STR("__eq__");
   if (fx_streq(&nstr_0, &slit_0)) {
      if (FX_REC_VARIANT_TAG(v_0) == 14) {
         _fx_LN10Ast__typ_t v_2 = v_0->u.TypFun.t0;
         if (v_2 != 0) {
            _fx_LN10Ast__typ_t v_3 = v_2->tl;
            if (v_3 != 0) {
               if (v_3->tl == 0) {
                  _fx_N10Ast__typ_t v_4 = v_3->hd;
                  if (FX_REC_VARIANT_TAG(v_4) == 24) {
                     _fx_N10Ast__typ_t v_5 = v_2->hd;
                     if (FX_REC_VARIANT_TAG(v_5) == 24) {
                        _fx_R9Ast__id_t* n1_0 = &v_5->u.TypApp.t1;
                        bool res_0;
                        FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(n1_0, &v_4->u.TypApp.t1, &res_0, 0), _fx_cleanup);
                        bool t_1;
                        if (res_0) {
                           FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(n1_0, loc_0, &v_1, 0), _fx_cleanup);
                           if (v_1.tag == 6) {
                              t_1 = true;
                           }
                           else {
                              t_1 = false;
                           }
                           FX_CHECK_EXN(_fx_cleanup);
                        }
                        else {
                           t_1 = false;
                        }
                        if (t_1) {
                           _fx_T2R9Ast__id_tN10Ast__typ_t v_6 = {0};
                           _fx_R9Ast__id_t v_7;
                           fx_str_t slit_1 = FX_MAKE_STR("__eq_variants__");
                           FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&slit_1, &v_7, 0), _fx_catch_0);
                           FX_CALL(
                              _fx_M13Ast_typecheckFM9lookup_idT2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                                 &v_7, t_0, env_0, sc_0, loc_0, &v_6, 0), _fx_catch_0);
                           _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_6,
                              fx_result);

                        _fx_catch_0: ;
                           _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_6);
                           goto _fx_endmatch_0;
                        }
                     }
                  }
               }
            }
         }
      }
   }
   fx_str_t slit_2 = FX_MAKE_STR("string");
   if (fx_streq(&nstr_0, &slit_2)) {
      if (FX_REC_VARIANT_TAG(v_0) == 14) {
         _fx_LN10Ast__typ_t v_8 = v_0->u.TypFun.t0;
         if (v_8 != 0) {
            if (v_8->tl == 0) {
               if (FX_REC_VARIANT_TAG(v_8->hd) == 14) {
                  _fx_T2R9Ast__id_tN10Ast__typ_t v_9 = {0};
                  _fx_R9Ast__id_t v_10;
                  fx_str_t slit_3 = FX_MAKE_STR("__fun_string__");
                  FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&slit_3, &v_10, 0), _fx_catch_1);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM9lookup_idT2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                        &v_10, t_0, env_0, sc_0, loc_0, &v_9, 0), _fx_catch_1);
                  _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(&v_9, fx_result);

               _fx_catch_1: ;
                  _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_9);
                  goto _fx_endmatch_0;
               }
            }
         }
      }
   }
   _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, fx_result);

_fx_endmatch_0: ;

_fx_cleanup: ;
   FX_FREE_STR(&nstr_0);
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   _fx_free_N14Ast__id_info_t(&v_1);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM20preprocess_templ_typT2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5LR9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_LR9Ast__id_t_data_t* templ_args_0,
   struct _fx_N10Ast__typ_t_data_t* typ_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t t_0 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_0 = {0};
   _fx_N10Ast__typ_t v_0 = 0;
   int fx_status = 0;
   FX_CALL(_fx_M3AstFM7dup_typN10Ast__typ_t1N10Ast__typ_t(typ_0, &t_0, 0), _fx_cleanup);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &__fold_result___0);
   _fx_LR9Ast__id_t lst_0 = templ_args_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_1 = {0};
      _fx_N10Ast__typ_t t_1 = 0;
      _fx_LN16Ast__env_entry_t entries_0 = 0;
      _fx_N16Ast__env_entry_t v_1 = 0;
      _fx_LN16Ast__env_entry_t v_2 = 0;
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_3 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t v_4 = {0};
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_5 = 0;
      _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_6 = {0};
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t v_7 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_8 = {0};
      _fx_R9Ast__id_t* nt_0 = &lst_0->hd;
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env1_1);
      FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&t_1, 0), _fx_catch_1);
      FX_CALL(
         _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(nt_0, &env1_1,
            &entries_0, 0), _fx_catch_1);
      FX_CALL(_fx_M3AstFM6EnvTypN16Ast__env_entry_t1N10Ast__typ_t(t_1, &v_1), _fx_catch_1);
      FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_1, entries_0, true, &v_2), _fx_catch_1);
      FX_COPY_PTR(env1_1.root, &v_3);
      FX_COPY_FP(&env1_1.cmp, &v_4);
      FX_CALL(
         _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
            v_3, nt_0, v_2, &v_4, &v_5, 0), _fx_catch_1);
      if ((v_5 != 0) + 1 == 2) {
         _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
            vcase_0 = &v_5->u.Node;
         if (vcase_0->t0.tag == 1) {
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_9 = 0;
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_9), _fx_catch_0);
            _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_9, false, &v_6);

         _fx_catch_0: ;
            if (v_9) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_9);
            }
            goto _fx_endmatch_0;
         }
      }
      _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_5, true, &v_6);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_1);
      FX_COPY_PTR(v_6.t0, &new_root_0);
      FX_COPY_FP(&env1_1.cmp, &v_7);
      _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_7, &v_8);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_8, &__fold_result___0);

   _fx_catch_1: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_8);
      FX_FREE_FP(&v_7);
      if (new_root_0) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
      }
      _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_6);
      if (v_5) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_5);
      }
      FX_FREE_FP(&v_4);
      if (v_3) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_3);
      }
      if (v_2) {
         _fx_free_LN16Ast__env_entry_t(&v_2);
      }
      if (v_1) {
         _fx_free_N16Ast__env_entry_t(&v_1);
      }
      if (entries_0) {
         _fx_free_LN16Ast__env_entry_t(&entries_0);
      }
      if (t_1) {
         _fx_free_N10Ast__typ_t(&t_1);
      }
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_1);
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env1_0);
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
         t_0, &env1_0, sc_0, loc_0, &v_0, 0), _fx_cleanup);
   _fx_make_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_0, &env1_0, fx_result);

_fx_cleanup: ;
   if (t_0) {
      _fx_free_N10Ast__typ_t(&t_0);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0);
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM23check_for_duplicate_funFPv1N14Ast__id_info_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* ftyp_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_FPv1N14Ast__id_info_t* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t4Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tR10Ast__loc_tLN12Ast__scope_t(
      env_0, ftyp_0, loc_0, sc_0, fx_result);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t(struct _fx_N14Ast__id_info_t* i_0, void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t_cldata_t*)fx_fv;
   _fx_N10Ast__typ_t ftyp_0 = cv_0->t1;
   _fx_R10Ast__loc_t* loc_0 = &cv_0->t2;
   _fx_LN12Ast__scope_t sc_0 = cv_0->t3;
   int tag_0 = i_0->tag;
   if (tag_0 == 3) {
      _fx_R13Ast__deffun_t v_0 = {0};
      _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_1 = {0};
      _fx_N10Ast__typ_t t_0 = 0;
      fx_str_t v_2 = {0};
      fx_str_t v_3 = {0};
      fx_str_t v_4 = {0};
      fx_exn_t v_5 = {0};
      _fx_copy_R13Ast__deffun_t(&i_0->u.IdFun->data, &v_0);
      _fx_LN12Ast__scope_t df_scope_0 = v_0.df_scope;
      _fx_LR9Ast__id_t df_templ_args_0 = v_0.df_templ_args;
      _fx_N12Ast__scope_t v_6;
      if (df_scope_0 != 0) {
         v_6 = df_scope_0->hd;
      }
      else {
         FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_0);
      }
      FX_CHECK_EXN(_fx_catch_0);
      _fx_N12Ast__scope_t v_7;
      if (sc_0 != 0) {
         v_7 = sc_0->hd;
      }
      else {
         FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_0);
      }
      FX_CHECK_EXN(_fx_catch_0);
      bool res_0;
      FX_CALL(_fx_M13Ast_typecheckFM15__eq_variants__B2N12Ast__scope_tN12Ast__scope_t(&v_6, &v_7, &res_0, 0), _fx_catch_0);
      if (res_0) {
         FX_CALL(
            _fx_M13Ast_typecheckFM20preprocess_templ_typT2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5LR9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               df_templ_args_0, v_0.df_typ, &cv_0->t0, sc_0, loc_0, &v_1, 0), _fx_catch_0);
         FX_COPY_PTR(v_1.t0, &t_0);
         bool v_8;
         bool res_1;
         FX_CALL(
            _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t_0, ftyp_0, loc_0, false, &res_1, 0),
            _fx_catch_0);
         if (res_1) {
            v_8 = df_templ_args_0 == 0;
         }
         else {
            v_8 = false;
         }
         if (v_8) {
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_0.df_name, &v_2, 0), _fx_catch_0);
            FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(&v_0.df_loc, &v_3, 0), _fx_catch_0);
            fx_str_t slit_0 = FX_MAKE_STR("the symbol ");
            fx_str_t slit_1 = FX_MAKE_STR(" is re-declared in the same scope; the previous declaration is here: ");
            {
               const fx_str_t strs_0[] = { slit_0, v_2, slit_1, v_3 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_0, 4, &v_4), _fx_catch_0);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_4, &v_5, 0), _fx_catch_0);
            FX_THROW(&v_5, false, _fx_catch_0);
         }
      }

   _fx_catch_0: ;
      fx_free_exn(&v_5);
      FX_FREE_STR(&v_4);
      FX_FREE_STR(&v_3);
      FX_FREE_STR(&v_2);
      if (t_0) {
         _fx_free_N10Ast__typ_t(&t_0);
      }
      _fx_free_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_1);
      _fx_free_R13Ast__deffun_t(&v_0);
   }
   else if (tag_0 == 4) {
      _fx_R13Ast__defexn_t v_9 = {0};
      _fx_N10Ast__typ_t t_1 = 0;
      fx_str_t v_10 = {0};
      fx_str_t v_11 = {0};
      fx_str_t v_12 = {0};
      fx_exn_t v_13 = {0};
      _fx_copy_R13Ast__defexn_t(&i_0->u.IdExn->data, &v_9);
      _fx_LN12Ast__scope_t dexn_scope_0 = v_9.dexn_scope;
      _fx_N10Ast__typ_t dexn_typ_0 = v_9.dexn_typ;
      _fx_N12Ast__scope_t v_14;
      if (dexn_scope_0 != 0) {
         v_14 = dexn_scope_0->hd;
      }
      else {
         FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_3);
      }
      FX_CHECK_EXN(_fx_catch_3);
      _fx_N12Ast__scope_t v_15;
      if (sc_0 != 0) {
         v_15 = sc_0->hd;
      }
      else {
         FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_3);
      }
      FX_CHECK_EXN(_fx_catch_3);
      bool res_2;
      FX_CALL(_fx_M13Ast_typecheckFM15__eq_variants__B2N12Ast__scope_tN12Ast__scope_t(&v_14, &v_15, &res_2, 0), _fx_catch_3);
      if (res_2) {
         if (FX_REC_VARIANT_TAG(dexn_typ_0) == 13) {
            FX_COPY_PTR(_fx_g21Ast_typecheck__TypExn, &t_1);
         }
         else {
            _fx_LN10Ast__typ_t v_16 = 0;
            if (FX_REC_VARIANT_TAG(dexn_typ_0) == 17) {
               FX_COPY_PTR(dexn_typ_0->u.TypTuple, &v_16);
            }
            else {
               FX_CALL(_fx_cons_LN10Ast__typ_t(dexn_typ_0, 0, true, &v_16), _fx_catch_1);  _fx_catch_1: ;
            }
            FX_CHECK_EXN(_fx_catch_2);
            FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(v_16, _fx_g21Ast_typecheck__TypExn, &t_1),
               _fx_catch_2);

         _fx_catch_2: ;
            if (v_16) {
               _fx_free_LN10Ast__typ_t(&v_16);
            }
         }
         FX_CHECK_EXN(_fx_catch_3);
         bool v_17;
         FX_CALL(
            _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t_1, ftyp_0, loc_0, false, &v_17, 0),
            _fx_catch_3);
         if (v_17) {
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_9.dexn_name, &v_10, 0), _fx_catch_3);
            FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(&v_9.dexn_loc, &v_11, 0), _fx_catch_3);
            fx_str_t slit_2 = FX_MAKE_STR("the symbol \'");
            fx_str_t slit_3 = FX_MAKE_STR("\' is re-declared in the same scope; the previous declaration is here ");
            {
               const fx_str_t strs_1[] = { slit_2, v_10, slit_3, v_11 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_1, 4, &v_12), _fx_catch_3);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_12, &v_13, 0), _fx_catch_3);
            FX_THROW(&v_13, false, _fx_catch_3);
         }
      }

   _fx_catch_3: ;
      fx_free_exn(&v_13);
      FX_FREE_STR(&v_12);
      FX_FREE_STR(&v_11);
      FX_FREE_STR(&v_10);
      if (t_1) {
         _fx_free_N10Ast__typ_t(&t_1);
      }
      _fx_free_R13Ast__defexn_t(&v_9);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t4Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tR10Ast__loc_tLN12Ast__scope_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_R10Ast__loc_t* arg2,
   struct _fx_LN12Ast__scope_t_data_t* arg3,
   struct _fx_FPv1N14Ast__id_info_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t_cldata_t,
      _fx_free_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t, _fx_M13Ast_typecheckFM12__lambda__1_v1N14Ast__id_info_t);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(arg0, &fcv->t0);
   FX_COPY_PTR(arg1, &fcv->t1);
   fcv->t2 = *arg2;
   FX_COPY_PTR(arg3, &fcv->t3);
   return 0;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM26check_for_duplicate_methodFPv1N14Ast__id_info_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_FPv1N14Ast__id_info_t* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t2R10Ast__loc_tN10Ast__typ_t(loc_0, t_0, fx_result);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t(struct _fx_N14Ast__id_info_t* i_0, void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t_cldata_t*)fx_fv;
   _fx_R10Ast__loc_t* loc_0 = &cv_0->t0;
   if (i_0->tag == 2) {
      _fx_R13Ast__defval_t* v_0 = &i_0->u.IdDVal;
      _fx_LN12Ast__scope_t v_1 = v_0->dv_scope;
      if (v_1 != 0) {
         if (v_1->hd.tag == 9) {
            bool res_0;
            FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_0->dv_flags.val_flag_method.t0, &_fx_g9Ast__noid, &res_0, 0),
               _fx_cleanup);
            if (!res_0) {
               fx_str_t v_2 = {0};
               fx_str_t v_3 = {0};
               fx_str_t v_4 = {0};
               fx_exn_t v_5 = {0};
               bool v_6;
               FX_CALL(
                  _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(cv_0->t1, v_0->dv_typ, loc_0,
                     false, &v_6, 0), _fx_catch_0);
               if (v_6) {
                  FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_0->dv_name, &v_2, 0), _fx_catch_0);
                  FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(&v_0->dv_loc, &v_3, 0), _fx_catch_0);
                  fx_str_t slit_0 = FX_MAKE_STR("the interface method ");
                  fx_str_t slit_1 = FX_MAKE_STR(" is re-declared in the same scope; the previous declaration is here: ");
                  {
                     const fx_str_t strs_0[] = { slit_0, v_2, slit_1, v_3 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_0, 4, &v_4), _fx_catch_0);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_4, &v_5, 0), _fx_catch_0);
                  FX_THROW(&v_5, false, _fx_catch_0);
               }

            _fx_catch_0: ;
               fx_free_exn(&v_5);
               FX_FREE_STR(&v_4);
               FX_FREE_STR(&v_3);
               FX_FREE_STR(&v_2);
               goto _fx_endmatch_0;
            }
         }
      }
   }

_fx_endmatch_0: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPv1N14Ast__id_info_t2R10Ast__loc_tN10Ast__typ_t(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_N10Ast__typ_t_data_t* arg1,
   struct _fx_FPv1N14Ast__id_info_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t_cldata_t,
      _fx_free_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t, _fx_M13Ast_typecheckFM12__lambda__2_v1N14Ast__id_info_t);
   fcv->t0 = *arg0;
   FX_COPY_PTR(arg1, &fcv->t1);
   return 0;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM21check_and_norm_tyargsLN10Ast__typ_t4LN10Ast__typ_tLR9Ast__id_tR10Ast__loc_tR10Ast__loc_t(
   struct _fx_LN10Ast__typ_t_data_t* actual_ty_args_0,
   struct _fx_LR9Ast__id_t_data_t* templ_args_0,
   struct _fx_R10Ast__loc_t* def_loc_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   struct _fx_LN10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   int_ n_aty_args_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(actual_ty_args_0, 0);
   int_ n_templ_args_0 = _fx_M13Ast_typecheckFM6lengthi1LR9Ast__id_t(templ_args_0, 0);
   if (n_aty_args_0 == n_templ_args_0) {
      FX_COPY_PTR(actual_ty_args_0, fx_result); goto _fx_endmatch_0;
   }
   if (n_aty_args_0 == 1) {
      if (actual_ty_args_0 != 0) {
         if (actual_ty_args_0->tl == 0) {
            _fx_N10Ast__typ_t v_0 = actual_ty_args_0->hd;
            if (FX_REC_VARIANT_TAG(v_0) == 17) {
               _fx_LN10Ast__typ_t tl_0 = v_0->u.TypTuple;
               int_ v_1 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(tl_0, 0);
               if (v_1 == n_templ_args_0) {
                  FX_COPY_PTR(tl_0, fx_result); goto _fx_endmatch_0;
               }
            }
         }
      }
   }
   if (n_templ_args_0 == 1) {
      _fx_N10Ast__typ_t v_2 = 0;
      FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(actual_ty_args_0, &v_2), _fx_catch_0);
      FX_CALL(_fx_cons_LN10Ast__typ_t(v_2, 0, true, fx_result), _fx_catch_0);

   _fx_catch_0: ;
      if (v_2) {
         _fx_free_N10Ast__typ_t(&v_2);
      }
      goto _fx_endmatch_0;
   }
   fx_str_t v_3 = {0};
   fx_str_t v_4 = {0};
   fx_str_t v_5 = {0};
   fx_str_t v_6 = {0};
   fx_exn_t v_7 = {0};
   FX_CALL(_fx_F6stringS1i(n_aty_args_0, &v_3, 0), _fx_catch_1);
   FX_CALL(_fx_F6stringS1i(n_templ_args_0, &v_4, 0), _fx_catch_1);
   FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(def_loc_0, &v_5, 0), _fx_catch_1);
   fx_str_t slit_0 = FX_MAKE_STR("the number of actual type arguments (");
   fx_str_t slit_1 = FX_MAKE_STR(") does not match the number of formal type parameters (");
   fx_str_t slit_2 =
      FX_MAKE_STR("), as declared at\n"
         U"\t");
   {
      const fx_str_t strs_0[] = { slit_0, v_3, slit_1, v_4, slit_2, v_5 };
      FX_CALL(fx_strjoin(0, 0, 0, strs_0, 6, &v_6), _fx_catch_1);
   }
   FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &v_6, &v_7, 0), _fx_catch_1);
   FX_THROW(&v_7, false, _fx_catch_1);

_fx_catch_1: ;
   fx_free_exn(&v_7);
   FX_FREE_STR(&v_6);
   FX_FREE_STR(&v_5);
   FX_FREE_STR(&v_4);
   FX_FREE_STR(&v_3);

_fx_endmatch_0: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM19match_ty_templ_argsRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5LN10Ast__typ_tLR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tR10Ast__loc_t(
   struct _fx_LN10Ast__typ_t_data_t* actual_ty_args_0,
   struct _fx_LR9Ast__id_t_data_t* templ_args_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_R10Ast__loc_t* def_loc_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_LN10Ast__typ_t norm_ty_args_0 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
   int fx_status = 0;
   FX_CALL(
      _fx_M13Ast_typecheckFM21check_and_norm_tyargsLN10Ast__typ_t4LN10Ast__typ_tLR9Ast__id_tR10Ast__loc_tR10Ast__loc_t(
         actual_ty_args_0, templ_args_0, def_loc_0, inst_loc_0, &norm_ty_args_0, 0), _fx_cleanup);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &__fold_result___0);
   _fx_LR9Ast__id_t lst_0 = templ_args_0;
   _fx_LN10Ast__typ_t lst_1 = norm_ty_args_0;
   for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl) {
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
      _fx_LN16Ast__env_entry_t entries_0 = 0;
      _fx_N16Ast__env_entry_t v_0 = 0;
      _fx_LN16Ast__env_entry_t v_1 = 0;
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_2 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t v_3 = {0};
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_4 = 0;
      _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_5 = {0};
      _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t v_6 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_7 = {0};
      _fx_N10Ast__typ_t t_0 = lst_1->hd;
      _fx_R9Ast__id_t* n_0 = &lst_0->hd;
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_1);
      FX_CALL(
         _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(n_0, &env_1,
            &entries_0, 0), _fx_catch_1);
      FX_CALL(_fx_M3AstFM6EnvTypN16Ast__env_entry_t1N10Ast__typ_t(t_0, &v_0), _fx_catch_1);
      FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_0, entries_0, true, &v_1), _fx_catch_1);
      FX_COPY_PTR(env_1.root, &v_2);
      FX_COPY_FP(&env_1.cmp, &v_3);
      FX_CALL(
         _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
            v_2, n_0, v_1, &v_3, &v_4, 0), _fx_catch_1);
      if ((v_4 != 0) + 1 == 2) {
         _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
            vcase_0 = &v_4->u.Node;
         if (vcase_0->t0.tag == 1) {
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_8 = 0;
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_8), _fx_catch_0);
            _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_8, false, &v_5);

         _fx_catch_0: ;
            if (v_8) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_8);
            }
            goto _fx_endmatch_0;
         }
      }
      _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_4, true, &v_5);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_1);
      FX_COPY_PTR(v_5.t0, &new_root_0);
      FX_COPY_FP(&env_1.cmp, &v_6);
      _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_6, &v_7);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_7, &__fold_result___0);

   _fx_catch_1: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_7);
      FX_FREE_FP(&v_6);
      if (new_root_0) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
      }
      _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_5);
      if (v_4) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
      }
      FX_FREE_FP(&v_3);
      if (v_2) {
         _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
      }
      if (v_1) {
         _fx_free_LN16Ast__env_entry_t(&v_1);
      }
      if (v_0) {
         _fx_free_N16Ast__env_entry_t(&v_0);
      }
      if (entries_0) {
         _fx_free_LN16Ast__env_entry_t(&entries_0);
      }
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
      FX_CHECK_EXN(_fx_cleanup);
   }
   int s_0 = !lst_0 + !lst_1;
   FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_cleanup);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, fx_result);

_fx_cleanup: ;
   if (norm_ty_args_0) {
      _fx_free_LN10Ast__typ_t(&norm_ty_args_0);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM19check_unary_bitwiseN10Ast__typ_t1N10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t v_0 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t_0, &v_0, 0), _fx_cleanup);
   int tag_0 = FX_REC_VARIANT_TAG(v_0);
   if (tag_0 == 5) {
      FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, fx_result);
   }
   else if (tag_0 == 6) {
      FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(v_0->u.TypSInt, fx_result), _fx_catch_0);  _fx_catch_0: ;
   }
   else if (tag_0 == 7) {
      FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(v_0->u.TypUInt, fx_result), _fx_catch_1);  _fx_catch_1: ;
   }
   else if (tag_0 == 12) {
      FX_COPY_PTR(_fx_g22Ast_typecheck__TypBool, fx_result);
   }
   else if (tag_0 == 17) {
      _fx_LN10Ast__typ_t v_1 = 0;
      _fx_LN10Ast__typ_t tl_0 = 0;
      _fx_LN10Ast__typ_t lstend_0 = 0;
      FX_COPY_PTR(v_0->u.TypTuple, &tl_0);
      _fx_LN10Ast__typ_t lst_0 = tl_0;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_N10Ast__typ_t res_0 = 0;
         _fx_N10Ast__typ_t x_0 = lst_0->hd;
         FX_CALL(_fx_M13Ast_typecheckFM19check_unary_bitwiseN10Ast__typ_t1N10Ast__typ_t(x_0, &res_0, 0), _fx_catch_2);
         _fx_LN10Ast__typ_t node_0 = 0;
         FX_CALL(_fx_cons_LN10Ast__typ_t(res_0, 0, false, &node_0), _fx_catch_2);
         FX_LIST_APPEND(v_1, lstend_0, node_0);

      _fx_catch_2: ;
         if (res_0) {
            _fx_free_N10Ast__typ_t(&res_0);
         }
         FX_CHECK_EXN(_fx_catch_3);
      }
      FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(v_1, fx_result), _fx_catch_3);

   _fx_catch_3: ;
      if (tl_0) {
         _fx_free_LN10Ast__typ_t(&tl_0);
      }
      if (v_1) {
         _fx_free_LN10Ast__typ_t(&v_1);
      }
   }
   else {
      FX_FAST_THROW(FX_EXN_BadArgError, _fx_cleanup);
   }

_fx_cleanup: ;
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__exp_t result_0 = 0;
   _fx_N10Ast__exp_t e_1 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   _fx_LN12Ast__scope_t sc_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_COPY_PTR(e_0, &e_1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &env_1);
   FX_COPY_PTR(sc_0, &sc_1);
   for (;;) {
      _fx_N10Ast__exp_t e_2 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
      _fx_LN12Ast__scope_t sc_2 = 0;
      _fx_T2N10Ast__typ_tR10Ast__loc_t ctx_0 = {0};
      _fx_N10Ast__typ_t etyp_0 = 0;
      FX_COPY_PTR(e_1, &e_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &env_2);
      FX_COPY_PTR(sc_1, &sc_2);
      FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e_2, &ctx_0, 0), _fx_catch_210);
      FX_COPY_PTR(ctx_0.t0, &etyp_0);
      _fx_R10Ast__loc_t eloc_0 = ctx_0.t1;
      int_ curr_m_idx_0;
      FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_2, &curr_m_idx_0, 0), _fx_catch_210);
      int tag_0 = FX_REC_VARIANT_TAG(e_2);
      if (tag_0 == 1) {
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(e_2, &result_0);
         FX_BREAK(_fx_catch_0);

      _fx_catch_0: ;
         goto _fx_endmatch_41;
      }
      if (tag_0 == 5) {
         _fx_Nt6option1N10Ast__exp_t new_e1_opt_0 = 0;
         _fx_Nt6option1N10Ast__exp_t new_e2_opt_0 = 0;
         _fx_Nt6option1N10Ast__exp_t new_e3_opt_0 = 0;
         _fx_LN10Ast__typ_t v_0 = 0;
         _fx_N10Ast__typ_t v_1 = 0;
         _fx_N10Ast__exp_t result_1 = 0;
         _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_0 =
            &e_2->u.ExpRange;
         _fx_Nt6option1N10Ast__exp_t e3_opt_0 = vcase_0->t2;
         FX_CALL(
            _fx_M13Ast_typecheckFM13check_range_eNt6option1N10Ast__exp_t3Nt6option1N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               vcase_0->t0, &env_2, sc_2, &new_e1_opt_0, 0), _fx_catch_3);
         FX_CALL(
            _fx_M13Ast_typecheckFM13check_range_eNt6option1N10Ast__exp_t3Nt6option1N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               vcase_0->t1, &env_2, sc_2, &new_e2_opt_0, 0), _fx_catch_3);
         if ((e3_opt_0 != 0) + 1 == 2) {
            FX_CALL(
               _fx_M13Ast_typecheckFM13check_range_eNt6option1N10Ast__exp_t3Nt6option1N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  e3_opt_0, &env_2, sc_2, &new_e3_opt_0, 0), _fx_catch_1);

         _fx_catch_1: ;
         }
         else {
            _fx_N10Ast__lit_t v_2 = {0};
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_3 = {0};
            _fx_N10Ast__exp_t v_4 = 0;
            _fx_M3AstFM6LitIntN10Ast__lit_t1l(1LL, &v_2);
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &eloc_0, &v_3);
            FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_2, &v_3, &v_4), _fx_catch_2);
            FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(v_4, &new_e3_opt_0), _fx_catch_2);

         _fx_catch_2: ;
            if (v_4) {
               _fx_free_N10Ast__exp_t(&v_4);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_3);
            _fx_free_N10Ast__lit_t(&v_2);
         }
         FX_CHECK_EXN(_fx_catch_3);
         FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, 0, true, &v_0), _fx_catch_3);
         FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, v_0, false, &v_0), _fx_catch_3);
         FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, v_0, false, &v_0), _fx_catch_3);
         FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(v_0, &v_1), _fx_catch_3);
         fx_str_t slit_0 = FX_MAKE_STR("the range type should have (int, int, int) type");
         FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_1, &eloc_0, &slit_0, 0),
            _fx_catch_3);
         FX_CALL(
            _fx_M3AstFM8ExpRangeN10Ast__exp_t4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
               new_e1_opt_0, new_e2_opt_0, new_e3_opt_0, &ctx_0, &result_1), _fx_catch_3);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_1, &result_0);
         FX_BREAK(_fx_catch_3);

      _fx_catch_3: ;
         if (result_1) {
            _fx_free_N10Ast__exp_t(&result_1);
         }
         if (v_1) {
            _fx_free_N10Ast__typ_t(&v_1);
         }
         if (v_0) {
            _fx_free_LN10Ast__typ_t(&v_0);
         }
         if (new_e3_opt_0) {
            _fx_free_Nt6option1N10Ast__exp_t(&new_e3_opt_0);
         }
         if (new_e2_opt_0) {
            _fx_free_Nt6option1N10Ast__exp_t(&new_e2_opt_0);
         }
         if (new_e1_opt_0) {
            _fx_free_Nt6option1N10Ast__exp_t(&new_e1_opt_0);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 6) {
         _fx_N10Ast__typ_t v_5 = 0;
         FX_CALL(_fx_M3AstFM11get_lit_typN10Ast__typ_t1N10Ast__lit_t(&e_2->u.ExpLit.t0, &v_5, 0), _fx_catch_4);
         fx_str_t slit_1 = FX_MAKE_STR("the literal has improper type");
         FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_5, &eloc_0, &slit_1, 0),
            _fx_catch_4);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(e_2, &result_0);
         FX_BREAK(_fx_catch_4);

      _fx_catch_4: ;
         if (v_5) {
            _fx_free_N10Ast__typ_t(&v_5);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 7) {
         _fx_T2R9Ast__id_tN10Ast__typ_t v_6 = {0};
         _fx_N10Ast__typ_t t_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_7 = {0};
         _fx_N10Ast__exp_t result_2 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM9lookup_idT2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               &e_2->u.ExpIdent.t0, etyp_0, &env_2, sc_2, &eloc_0, &v_6, 0), _fx_catch_5);
         _fx_R9Ast__id_t n_0 = v_6.t0;
         FX_COPY_PTR(v_6.t1, &t_0);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t_0, &eloc_0, &v_7);
         FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&n_0, &v_7, &result_2), _fx_catch_5);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_2, &result_0);
         FX_BREAK(_fx_catch_5);

      _fx_catch_5: ;
         if (result_2) {
            _fx_free_N10Ast__exp_t(&result_2);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_7);
         if (t_0) {
            _fx_free_N10Ast__typ_t(&t_0);
         }
         _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_6);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 21) {
         _fx_N10Ast__exp_t new_e1_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_8 = {0};
         _fx_N10Ast__typ_t etyp1_0 = 0;
         _fx_N10Ast__typ_t etyp1_1 = 0;
         _fx_N14Ast__id_info_t v_9 = {0};
         _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_1 = &e_2->u.ExpMem;
         _fx_N10Ast__exp_t e2_0 = vcase_1->t1;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               vcase_1->t0, &env_2, sc_2, &new_e1_0, 0), _fx_catch_22);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e1_0, &v_8, 0), _fx_catch_22);
         FX_COPY_PTR(v_8.t0, &etyp1_0);
         _fx_R10Ast__loc_t eloc1_0 = v_8.t1;
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp1_0, &etyp1_1, 0), _fx_catch_22);
         if (FX_REC_VARIANT_TAG(etyp1_1) == 26) {
            if (FX_REC_VARIANT_TAG(e2_0) == 7) {
               if (FX_REC_VARIANT_TAG(new_e1_0) == 7) {
                  _fx_N16Ast__defmodule_t dm_0 = 0;
                  _fx_T2R9Ast__id_tN10Ast__typ_t v_10 = {0};
                  _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
                  fx_str_t v_11 = {0};
                  fx_str_t v_12 = {0};
                  fx_str_t n1n2_0 = {0};
                  _fx_N10Ast__typ_t t_1 = 0;
                  _fx_T2N10Ast__typ_tR10Ast__loc_t v_13 = {0};
                  _fx_N10Ast__exp_t result_3 = 0;
                  _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t* vcase_2 = &new_e1_0->u.ExpIdent;
                  _fx_R9Ast__id_t* n1_0 = &vcase_2->t0;
                  _fx_R9Ast__id_t* n2_0 = &e2_0->u.ExpIdent.t0;
                  FX_CALL(_fx_M3AstFM10get_moduleN16Ast__defmodule_t2RM4id_tRM5loc_t(n1_0, &vcase_2->t1.t1, &dm_0, 0),
                     _fx_catch_6);
                  if (dm_0->u.defmodule_t.t3) {
                     if (curr_m_idx_0 == dm_0->u.defmodule_t.t2) {
                        _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &env_3);
                     }
                     else {
                        _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&dm_0->u.defmodule_t.t6, &env_3);
                     }
                     FX_CALL(
                        _fx_M13Ast_typecheckFM9lookup_idT2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                           n2_0, etyp_0, &env_3, sc_2, &eloc_0, &v_10, 0), _fx_catch_6);
                  }
                  else {
                     FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n1_0, &v_11, 0), _fx_catch_6);
                     FX_CALL(_fx_M3AstFM6stringS1RM4id_t(n2_0, &v_12, 0), _fx_catch_6);
                     fx_str_t slit_2 = FX_MAKE_STR(".");
                     {
                        const fx_str_t strs_0[] = { v_11, slit_2, v_12 };
                        FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &n1n2_0), _fx_catch_6);
                     }
                     _fx_R9Ast__id_t v_14;
                     FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&n1n2_0, &v_14, 0), _fx_catch_6);
                     FX_CALL(
                        _fx_M13Ast_typecheckFM9lookup_idT2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                           &v_14, etyp_0, &env_2, sc_2, &eloc_0, &v_10, 0), _fx_catch_6);
                  }
                  _fx_R9Ast__id_t new_n2_0 = v_10.t0;
                  FX_COPY_PTR(v_10.t1, &t_1);
                  _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t_1, &eloc_0, &v_13);
                  FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&new_n2_0, &v_13, &result_3),
                     _fx_catch_6);
                  _fx_free_N10Ast__exp_t(&result_0);
                  FX_COPY_PTR(result_3, &result_0);
                  FX_BREAK(_fx_catch_6);

               _fx_catch_6: ;
                  if (result_3) {
                     _fx_free_N10Ast__exp_t(&result_3);
                  }
                  _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_13);
                  if (t_1) {
                     _fx_free_N10Ast__typ_t(&t_1);
                  }
                  FX_FREE_STR(&n1n2_0);
                  FX_FREE_STR(&v_12);
                  FX_FREE_STR(&v_11);
                  _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
                  _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_10);
                  if (dm_0) {
                     _fx_free_N16Ast__defmodule_t(&dm_0);
                  }
                  goto _fx_endmatch_0;
               }
            }
         }
         if (FX_REC_VARIANT_TAG(e2_0) == 6) {
            _fx_T2N10Ast__lit_tT2N10Ast__typ_tR10Ast__loc_t* vcase_3 = &e2_0->u.ExpLit;
            _fx_N10Ast__lit_t* v_15 = &vcase_3->t0;
            if (v_15->tag == 1) {
               if (FX_REC_VARIANT_TAG(etyp1_1) == 17) {
                  _fx_N10Ast__typ_t et_0 = 0;
                  fx_exn_t exn_0 = {0};
                  _fx_N10Ast__exp_t result_4 = 0;
                  _fx_T2N10Ast__typ_tR10Ast__loc_t* v_16 = &vcase_3->t1;
                  _fx_R10Ast__loc_t* eloc2_0 = &v_16->t1;
                  fx_str_t slit_3 = FX_MAKE_STR("index must be int!");
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(v_16->t0,
                        _fx_g21Ast_typecheck__TypInt, eloc2_0, &slit_3, 0), _fx_catch_9);
                  int_ res_0;
                  FX_CALL(_fx_M13Ast_typecheckFM3inti1l(v_15->u.LitInt, &res_0, 0), _fx_catch_7);
                  FX_CALL(_fx_M13Ast_typecheckFM3nthN10Ast__typ_t2LN10Ast__typ_ti(etyp1_1->u.TypTuple, res_0, &et_0, 0),
                     _fx_catch_7);

               _fx_catch_7: ;
                  if (fx_status < 0) {
                     fx_exn_get_and_reset(fx_status, &exn_0);
                     fx_status = 0;
                     if (et_0) {
                        _fx_free_N10Ast__typ_t(&et_0);
                     }
                     if (exn_0.tag == FX_EXN_OutOfRangeError) {
                        fx_exn_t v_17 = {0};
                        fx_str_t slit_4 = FX_MAKE_STR("the tuple index is out of range");
                        FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc2_0, &slit_4, &v_17, 0), _fx_catch_8);
                        FX_THROW(&v_17, false, _fx_catch_8);

                     _fx_catch_8: ;
                        fx_free_exn(&v_17);
                     }
                     else {
                        FX_RETHROW(&exn_0, _fx_catch_9);
                     }
                     FX_CHECK_EXN(_fx_catch_9);
                  }
                  fx_str_t slit_5 = FX_MAKE_STR("incorrect type of the tuple element");
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, et_0, &eloc_0, &slit_5, 0),
                     _fx_catch_9);
                  FX_CALL(
                     _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_e1_0, e2_0, &ctx_0,
                        &result_4), _fx_catch_9);
                  _fx_free_N10Ast__exp_t(&result_0);
                  FX_COPY_PTR(result_4, &result_0);
                  FX_BREAK(_fx_catch_9);

               _fx_catch_9: ;
                  if (result_4) {
                     _fx_free_N10Ast__exp_t(&result_4);
                  }
                  fx_free_exn(&exn_0);
                  if (et_0) {
                     _fx_free_N10Ast__typ_t(&et_0);
                  }
                  goto _fx_endmatch_0;
               }
            }
         }
         if (FX_REC_VARIANT_TAG(e2_0) == 7) {
            if (FX_REC_VARIANT_TAG(etyp1_1) == 24) {
               bool res_1;
               FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&e2_0->u.ExpIdent.t0, &_fx_g15Ast__std__tag__, &res_1, 0),
                  _fx_catch_22);
               if (res_1) {
                  _fx_N14Ast__id_info_t v_18 = {0};
                  FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&etyp1_1->u.TypApp.t1, &eloc_0, &v_18, 0),
                     _fx_catch_12);
                  if (v_18.tag == 6) {
                     _fx_N10Ast__exp_t result_5 = 0;
                     fx_str_t slit_6 = FX_MAKE_STR("variant tag is integer, but the other type is expected");
                     FX_CALL(
                        _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0,
                           _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_6, 0), _fx_catch_10);
                     FX_CALL(
                        _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_e1_0, e2_0,
                           &ctx_0, &result_5), _fx_catch_10);
                     _fx_free_N10Ast__exp_t(&result_0);
                     FX_COPY_PTR(result_5, &result_0);
                     FX_BREAK(_fx_catch_10);

                  _fx_catch_10: ;
                     if (result_5) {
                        _fx_free_N10Ast__exp_t(&result_5);
                     }
                  }
                  else {
                     fx_exn_t v_19 = {0};
                     fx_str_t slit_7 = FX_MAKE_STR("__tag__ can only be requestd for variants and exceptions");
                     FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_7, &v_19, 0), _fx_catch_11);
                     FX_THROW(&v_19, false, _fx_catch_11);

                  _fx_catch_11: ;
                     fx_free_exn(&v_19);
                  }
                  FX_CHECK_EXN(_fx_catch_12);

               _fx_catch_12: ;
                  _fx_free_N14Ast__id_info_t(&v_18);
                  goto _fx_endmatch_0;
               }
            }
         }
         if (FX_REC_VARIANT_TAG(e2_0) == 7) {
            if (FX_REC_VARIANT_TAG(etyp1_1) == 24) {
               _fx_R9Ast__id_t* iname_0 = &etyp1_1->u.TypApp.t1;
               _fx_R9Ast__id_t* n2_1 = &e2_0->u.ExpIdent.t0;
               FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(iname_0, &eloc_0, &v_9, 0), _fx_catch_22);
               bool res_2;
               if (v_9.tag == 7) {
                  res_2 = true;
               }
               else {
                  res_2 = false;
               }
               FX_CHECK_EXN(_fx_catch_22);
               if (res_2) {
                  _fx_rR19Ast__definterface_t iface_0 = 0;
                  _fx_LN16Ast__env_entry_t candidates_0 = 0;
                  _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t __fold_result___0 = {0};
                  _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_20 = 0;
                  _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t method_opt_0 = {0};
                  FX_CALL(_fx_M3AstFM9get_ifacerRM14definterface_t2RM4id_tRM5loc_t(iname_0, &eloc_0, &iface_0, 0),
                     _fx_catch_16);
                  _fx_copy_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&_fx_g19Ast_typecheck__None,
                     &__fold_result___0);
                  FX_COPY_PTR(iface_0->data.di_all_methods, &v_20);
                  _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t lst_0 = v_20;
                  for (; lst_0; lst_0 = lst_0->tl) {
                     _fx_N10Ast__typ_t t_2 = 0;
                     _fx_N16Ast__env_entry_t v_21 = 0;
                     _fx_LN16Ast__env_entry_t v_22 = 0;
                     _fx_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_23 = {0};
                     _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* __pat___0 = &lst_0->hd;
                     _fx_R9Ast__id_t f_0 = __pat___0->t0;
                     FX_COPY_PTR(__pat___0->t1, &t_2);
                     _fx_R9Ast__id_t v_24;
                     FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&f_0, &v_24, 0), _fx_catch_13);
                     _fx_R9Ast__id_t v_25;
                     FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(n2_1, &v_25, 0), _fx_catch_13);
                     bool matched_name_0;
                     FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_24, &v_25, &matched_name_0, 0), _fx_catch_13);
                     if (matched_name_0) {
                        FX_CALL(_fx_M3AstFM5EnvIdN16Ast__env_entry_t1RM4id_t(&f_0, &v_21), _fx_catch_13);
                        FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_21, candidates_0, true, &v_22), _fx_catch_13);
                        _fx_free_LN16Ast__env_entry_t(&candidates_0);
                        FX_COPY_PTR(v_22, &candidates_0);
                     }
                     bool v_26;
                     if (matched_name_0) {
                        FX_CALL(
                           _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t_2, etyp_0, &eloc_0,
                              true, &v_26, 0), _fx_catch_13);
                     }
                     else {
                        v_26 = false;
                     }
                     if (v_26) {
                        _fx_M13Ast_typecheckFM4SomeNt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
                           __pat___0, &v_23);
                        _fx_free_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___0);
                        _fx_copy_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_23, &__fold_result___0);
                        FX_BREAK(_fx_catch_13);
                     }

                  _fx_catch_13: ;
                     _fx_free_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_23);
                     if (v_22) {
                        _fx_free_LN16Ast__env_entry_t(&v_22);
                     }
                     if (v_21) {
                        _fx_free_N16Ast__env_entry_t(&v_21);
                     }
                     if (t_2) {
                        _fx_free_N10Ast__typ_t(&t_2);
                     }
                     FX_CHECK_BREAK();
                     FX_CHECK_EXN(_fx_catch_16);
                  }
                  _fx_copy_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___0, &method_opt_0);
                  if (method_opt_0.tag == 2) {
                     _fx_T2N10Ast__typ_tR10Ast__loc_t v_27 = {0};
                     _fx_N10Ast__exp_t v_28 = 0;
                     _fx_N10Ast__exp_t result_6 = 0;
                     _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* v_29 = &method_opt_0.u.Some;
                     _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_29->t1, &eloc_0, &v_27);
                     FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&v_29->t0, &v_27, &v_28),
                        _fx_catch_14);
                     FX_CALL(
                        _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_e1_0, v_28,
                           &ctx_0, &result_6), _fx_catch_14);
                     _fx_free_N10Ast__exp_t(&result_0);
                     FX_COPY_PTR(result_6, &result_0);
                     FX_BREAK(_fx_catch_14);

                  _fx_catch_14: ;
                     if (result_6) {
                        _fx_free_N10Ast__exp_t(&result_6);
                     }
                     if (v_28) {
                        _fx_free_N10Ast__exp_t(&v_28);
                     }
                     _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_27);
                  }
                  else {
                     fx_exn_t v_30 = {0};
                     FX_CALL(
                        _fx_M13Ast_typecheckFM22report_not_found_typedE4R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_tR10Ast__loc_t(
                           n2_1, etyp_0, candidates_0, &eloc_0, &v_30, 0), _fx_catch_15);
                     FX_THROW(&v_30, false, _fx_catch_15);

                  _fx_catch_15: ;
                     fx_free_exn(&v_30);
                  }
                  FX_CHECK_EXN(_fx_catch_16);

               _fx_catch_16: ;
                  _fx_free_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&method_opt_0);
                  if (v_20) {
                     _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_20);
                  }
                  _fx_free_Nt6option1T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___0);
                  if (candidates_0) {
                     _fx_free_LN16Ast__env_entry_t(&candidates_0);
                  }
                  if (iface_0) {
                     _fx_free_rR19Ast__definterface_t(&iface_0);
                  }
                  goto _fx_endmatch_0;
               }
            }
         }
         if (FX_REC_VARIANT_TAG(etyp1_1) == 21) {
            if (FX_REC_VARIANT_TAG(e2_0) == 7) {
               bool res_3;
               FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&e2_0->u.ExpIdent.t0, &_fx_g15Ast__std__tag__, &res_3, 0),
                  _fx_catch_22);
               if (res_3) {
                  _fx_N10Ast__exp_t result_7 = 0;
                  fx_str_t slit_8 = FX_MAKE_STR("variant tag is integer, but the other type is expected");
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0,
                        _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_8, 0), _fx_catch_17);
                  FX_CALL(
                     _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_e1_0, e2_0, &ctx_0,
                        &result_7), _fx_catch_17);
                  _fx_free_N10Ast__exp_t(&result_0);
                  FX_COPY_PTR(result_7, &result_0);
                  FX_BREAK(_fx_catch_17);

               _fx_catch_17: ;
                  if (result_7) {
                     _fx_free_N10Ast__exp_t(&result_7);
                  }
                  goto _fx_endmatch_0;
               }
            }
         }
         if (FX_REC_VARIANT_TAG(e2_0) == 7) {
            _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_31 = {0};
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_0 = 0;
            _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t __lambda___0 = {0};
            _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_32 = {0};
            _fx_R9Ast__id_t* n2_2 = &e2_0->u.ExpIdent.t0;
            FX_CALL(
               _fx_M13Ast_typecheckFM16get_record_elemsT2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t4Nt6option1R9Ast__id_tN10Ast__typ_tBR10Ast__loc_t(
                  &_fx_g21Ast_typecheck__None9_, etyp1_1, false, &eloc1_0, &v_31, 0), _fx_catch_20);
            FX_COPY_PTR(v_31.t1, &relems_0);
            _fx_M13Ast_typecheckFM7make_fpFPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1R9Ast__id_t(n2_2,
               &__lambda___0);
            FX_CALL(
               _fx_M13Ast_typecheckFM8find_optNt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tFPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
                  relems_0, &__lambda___0, &v_32, 0), _fx_catch_20);
            if (v_32.tag == 2) {
               _fx_N10Ast__exp_t result_8 = 0;
               fx_str_t slit_9 = FX_MAKE_STR("incorrect type of the record element");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_32.u.Some.t2, &eloc_0,
                     &slit_9, 0), _fx_catch_18);
               FX_CALL(
                  _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_e1_0, e2_0, &ctx_0,
                     &result_8), _fx_catch_18);
               _fx_free_N10Ast__exp_t(&result_0);
               FX_COPY_PTR(result_8, &result_0);
               FX_BREAK(_fx_catch_18);

            _fx_catch_18: ;
               if (result_8) {
                  _fx_free_N10Ast__exp_t(&result_8);
               }
            }
            else {
               fx_str_t v_33 = {0};
               fx_str_t v_34 = {0};
               fx_str_t v_35 = {0};
               fx_exn_t v_36 = {0};
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n2_2, &v_33, 0), _fx_catch_19);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_33, &v_34, 0), _fx_catch_19);
               fx_str_t slit_10 = FX_MAKE_STR("the record element ");
               fx_str_t slit_11 = FX_MAKE_STR(" is not found");
               {
                  const fx_str_t strs_1[] = { slit_10, v_34, slit_11 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_1, 3, &v_35), _fx_catch_19);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_35, &v_36, 0), _fx_catch_19);
               FX_THROW(&v_36, false, _fx_catch_19);

            _fx_catch_19: ;
               fx_free_exn(&v_36);
               FX_FREE_STR(&v_35);
               FX_FREE_STR(&v_34);
               FX_FREE_STR(&v_33);
            }
            FX_CHECK_EXN(_fx_catch_20);

         _fx_catch_20: ;
            _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_32);
            FX_FREE_FP(&__lambda___0);
            if (relems_0) {
               _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_0);
            }
            _fx_free_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_31);
            goto _fx_endmatch_0;
         }
         fx_exn_t v_37 = {0};
         fx_str_t slit_12 = FX_MAKE_STR("unsupported element access operation");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_12, &v_37, 0), _fx_catch_21);
         FX_THROW(&v_37, false, _fx_catch_21);

      _fx_catch_21: ;
         fx_free_exn(&v_37);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_22);

      _fx_catch_22: ;
         _fx_free_N14Ast__id_info_t(&v_9);
         if (etyp1_1) {
            _fx_free_N10Ast__typ_t(&etyp1_1);
         }
         if (etyp1_0) {
            _fx_free_N10Ast__typ_t(&etyp1_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_8);
         if (new_e1_0) {
            _fx_free_N10Ast__exp_t(&new_e1_0);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 20) {
         _fx_N10Ast__exp_t new_e1_1 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t ectx_0 = {0};
         _fx_N10Ast__typ_t etyp1_2 = 0;
         _fx_N10Ast__exp_t e2_1 = 0;
         _fx_N10Ast__exp_t new_e2_0 = 0;
         fx_exn_t v_38 = {0};
         fx_exn_t v_39 = {0};
         _fx_N10Ast__exp_t result_9 = 0;
         _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t* vcase_4 = &e_2->u.ExpAssign;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               vcase_4->t0, &env_2, sc_2, &new_e1_1, 0), _fx_catch_23);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e1_1, &ectx_0, 0), _fx_catch_23);
         FX_COPY_PTR(ectx_0.t0, &etyp1_2);
         _fx_R10Ast__loc_t eloc1_1 = ectx_0.t1;
         fx_str_t slit_13 = FX_MAKE_STR("the left and the right sides of the assignment must have the same type");
         FX_CALL(
            _fx_M13Ast_typecheckFM22try_unify_with_literalN10Ast__exp_t3N10Ast__typ_tN10Ast__exp_tS(etyp1_2, vcase_4->t1,
               &slit_13, &e2_1, 0), _fx_catch_23);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e2_1, &env_2, sc_2, &new_e2_0, 0), _fx_catch_23);
         bool v_40;
         FX_CALL(
            _fx_M13Ast_typecheckFM9is_lvalueB4BN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_t(true, new_e1_1, &ectx_0,
               &eloc_0, &v_40, 0), _fx_catch_23);
         if (!v_40) {
            bool v_41;
            FX_CALL(
               _fx_M13Ast_typecheckFM32is_mutable_lvalue_identifier_expB3N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_t(
                  new_e1_1, &ectx_0, &eloc_0, &v_41, 0), _fx_catch_23);
            if (!v_41) {
               fx_str_t slit_14 = FX_MAKE_STR("the left side of an assignment is an immutable value");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc1_1, &slit_14, &v_38, 0), _fx_catch_23);
               FX_THROW(&v_38, false, _fx_catch_23);
            }
            else {
               fx_str_t slit_15 = FX_MAKE_STR("the left side of an assignment is not an l-value");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc1_1, &slit_15, &v_39, 0), _fx_catch_23);
               FX_THROW(&v_39, false, _fx_catch_23);
            }
         }
         FX_CALL(_fx_M3AstFM9ExpAssignN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tRM5loc_t(new_e1_1, new_e2_0, &eloc_0, &result_9),
            _fx_catch_23);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_9, &result_0);
         FX_BREAK(_fx_catch_23);

      _fx_catch_23: ;
         if (result_9) {
            _fx_free_N10Ast__exp_t(&result_9);
         }
         fx_free_exn(&v_39);
         fx_free_exn(&v_38);
         if (new_e2_0) {
            _fx_free_N10Ast__exp_t(&new_e2_0);
         }
         if (e2_1) {
            _fx_free_N10Ast__exp_t(&e2_1);
         }
         if (etyp1_2) {
            _fx_free_N10Ast__typ_t(&etyp1_2);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&ectx_0);
         if (new_e1_1) {
            _fx_free_N10Ast__exp_t(&new_e1_1);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 8) {
         _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_5 = &e_2->u.ExpBinary;
         if (FX_REC_VARIANT_TAG(vcase_5->t0) == 26) {
            _fx_N10Ast__exp_t new_e1_2 = 0;
            _fx_N10Ast__exp_t new_e2_1 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_42 = {0};
            _fx_N10Ast__typ_t etyp1_3 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_43 = {0};
            _fx_N10Ast__typ_t etyp2_0 = 0;
            _fx_N10Ast__typ_t v_44 = 0;
            _fx_N10Ast__typ_t v_45 = 0;
            _fx_N10Ast__typ_t v_46 = 0;
            _fx_N10Ast__typ_t v_47 = 0;
            _fx_N10Ast__typ_t v_48 = 0;
            fx_str_t v_49 = {0};
            fx_str_t v_50 = {0};
            fx_str_t v_51 = {0};
            fx_str_t v_52 = {0};
            fx_str_t v_53 = {0};
            fx_str_t v_54 = {0};
            fx_str_t v_55 = {0};
            fx_str_t v_56 = {0};
            fx_str_t v_57 = {0};
            fx_str_t v_58 = {0};
            _fx_N10Ast__exp_t result_10 = 0;
            _fx_LN10Ast__typ_t v_59 = 0;
            _fx_N10Ast__typ_t v_60 = 0;
            _fx_Nt6option1N10Ast__exp_t v_61 = 0;
            _fx_Nt6option1N10Ast__exp_t v_62 = 0;
            _fx_N10Ast__exp_t result_11 = 0;
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  vcase_5->t1, &env_2, sc_2, &new_e1_2, 0), _fx_catch_24);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  vcase_5->t2, &env_2, sc_2, &new_e2_1, 0), _fx_catch_24);
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e1_2, &v_42, 0), _fx_catch_24);
            FX_COPY_PTR(v_42.t0, &etyp1_3);
            _fx_R10Ast__loc_t eloc1_2 = v_42.t1;
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e2_1, &v_43, 0), _fx_catch_24);
            FX_COPY_PTR(v_43.t0, &etyp2_0);
            _fx_R10Ast__loc_t eloc2_1 = v_43.t1;
            FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_44, 0), _fx_catch_24);
            FX_CALL(_fx_M3AstFM7TypListN10Ast__typ_t1N10Ast__typ_t(v_44, &v_45), _fx_catch_24);
            bool v_63;
            bool res_4;
            FX_CALL(
               _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(etyp_0, v_45, &eloc_0, false,
                  &res_4, 0), _fx_catch_24);
            if (res_4) {
               v_63 = true;
            }
            else {
               FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_46, 0), _fx_catch_24);
               FX_CALL(_fx_M3AstFM7TypListN10Ast__typ_t1N10Ast__typ_t(v_46, &v_47), _fx_catch_24);
               FX_CALL(
                  _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(etyp2_0, v_47, &eloc_0, false,
                     &v_63, 0), _fx_catch_24);
            }
            if (v_63) {
               FX_CALL(_fx_M3AstFM7TypListN10Ast__typ_t1N10Ast__typ_t(etyp1_3, &v_48), _fx_catch_24);
               FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp1_3, &v_49, 0), _fx_catch_24);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_49, &v_50, 0), _fx_catch_24);
               FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp2_0, &v_51, 0), _fx_catch_24);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_51, &v_52, 0), _fx_catch_24);
               fx_str_t slit_16 = FX_MAKE_STR("incompatible types of arguments of \'::\' operation: \'");
               fx_str_t slit_17 = FX_MAKE_STR("\' and \'");
               fx_str_t slit_18 = FX_MAKE_STR("\'");
               {
                  const fx_str_t strs_2[] = { slit_16, v_50, slit_17, v_52, slit_18 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_2, 5, &v_53), _fx_catch_24);
               }
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp2_0, v_48, &eloc2_1, &v_53, 0),
                  _fx_catch_24);
               FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp2_0, &v_54, 0), _fx_catch_24);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_54, &v_55, 0), _fx_catch_24);
               FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp_0, &v_56, 0), _fx_catch_24);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_56, &v_57, 0), _fx_catch_24);
               fx_str_t slit_19 = FX_MAKE_STR("the produced list has type \'");
               fx_str_t slit_20 = FX_MAKE_STR("\', but it\'s expected to be \'");
               fx_str_t slit_21 = FX_MAKE_STR("\'");
               {
                  const fx_str_t strs_3[] = { slit_19, v_55, slit_20, v_57, slit_21 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_3, 5, &v_58), _fx_catch_24);
               }
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, etyp2_0, &eloc1_2, &v_58, 0),
                  _fx_catch_24);
               FX_CALL(
                  _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                     _fx_g21Ast_typecheck__OpCons, new_e1_2, new_e2_1, &ctx_0, &result_10), _fx_catch_24);
               _fx_free_N10Ast__exp_t(&result_0);
               FX_COPY_PTR(result_10, &result_0);
               FX_BREAK(_fx_catch_24);
            }
            else {
               fx_str_t slit_22 = FX_MAKE_STR("explicitly specified component of a range must be an integer");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp1_3, _fx_g21Ast_typecheck__TypInt,
                     &eloc1_2, &slit_22, 0), _fx_catch_24);
               fx_str_t slit_23 = FX_MAKE_STR("explicitly specified component of a range must be an integer");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp2_0, _fx_g21Ast_typecheck__TypInt,
                     &eloc2_1, &slit_23, 0), _fx_catch_24);
               FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, 0, true, &v_59), _fx_catch_24);
               FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, v_59, false, &v_59), _fx_catch_24);
               FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, v_59, false, &v_59), _fx_catch_24);
               FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(v_59, &v_60), _fx_catch_24);
               fx_str_t slit_24 = FX_MAKE_STR("the range type should have (int, int, int) type");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_60, &eloc_0, &slit_24, 0),
                  _fx_catch_24);
               FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(new_e1_2, &v_61), _fx_catch_24);
               FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(new_e2_1, &v_62), _fx_catch_24);
               FX_CALL(
                  _fx_M3AstFM8ExpRangeN10Ast__exp_t4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                     v_61, _fx_g22Ast_typecheck__None10_, v_62, &ctx_0, &result_11), _fx_catch_24);
               _fx_free_N10Ast__exp_t(&result_0);
               FX_COPY_PTR(result_11, &result_0);
               FX_BREAK(_fx_catch_24);
            }

         _fx_catch_24: ;
            if (result_11) {
               _fx_free_N10Ast__exp_t(&result_11);
            }
            if (v_62) {
               _fx_free_Nt6option1N10Ast__exp_t(&v_62);
            }
            if (v_61) {
               _fx_free_Nt6option1N10Ast__exp_t(&v_61);
            }
            if (v_60) {
               _fx_free_N10Ast__typ_t(&v_60);
            }
            if (v_59) {
               _fx_free_LN10Ast__typ_t(&v_59);
            }
            if (result_10) {
               _fx_free_N10Ast__exp_t(&result_10);
            }
            FX_FREE_STR(&v_58);
            FX_FREE_STR(&v_57);
            FX_FREE_STR(&v_56);
            FX_FREE_STR(&v_55);
            FX_FREE_STR(&v_54);
            FX_FREE_STR(&v_53);
            FX_FREE_STR(&v_52);
            FX_FREE_STR(&v_51);
            FX_FREE_STR(&v_50);
            FX_FREE_STR(&v_49);
            if (v_48) {
               _fx_free_N10Ast__typ_t(&v_48);
            }
            if (v_47) {
               _fx_free_N10Ast__typ_t(&v_47);
            }
            if (v_46) {
               _fx_free_N10Ast__typ_t(&v_46);
            }
            if (v_45) {
               _fx_free_N10Ast__typ_t(&v_45);
            }
            if (v_44) {
               _fx_free_N10Ast__typ_t(&v_44);
            }
            if (etyp2_0) {
               _fx_free_N10Ast__typ_t(&etyp2_0);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_43);
            if (etyp1_3) {
               _fx_free_N10Ast__typ_t(&etyp1_3);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_42);
            if (new_e2_1) {
               _fx_free_N10Ast__exp_t(&new_e2_1);
            }
            if (new_e1_2) {
               _fx_free_N10Ast__exp_t(&new_e1_2);
            }
            goto _fx_endmatch_41;
         }
      }
      if (tag_0 == 8) {
         _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_6 = &e_2->u.ExpBinary;
         _fx_N13Ast__binary_t bop_0 = vcase_6->t0;
         if (FX_REC_VARIANT_TAG(bop_0) == 21) {
            _fx_N10Ast__exp_t new_e1_3 = 0;
            _fx_N10Ast__exp_t new_e2_2 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_64 = {0};
            _fx_N10Ast__typ_t etyp1_4 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_65 = {0};
            _fx_N10Ast__typ_t etyp2_1 = 0;
            _fx_Ta2N10Ast__exp_t v_66 = {0};
            _fx_N10Ast__exp_t new_e1_4 = 0;
            _fx_N10Ast__exp_t new_e2_3 = 0;
            fx_str_t v_67 = {0};
            fx_str_t v_68 = {0};
            _fx_N10Ast__exp_t result_12 = 0;
            _fx_Nt6option1N10Ast__exp_t result_exp_opt_0 = 0;
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  vcase_6->t1, &env_2, sc_2, &new_e1_3, 0), _fx_catch_37);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  vcase_6->t2, &env_2, sc_2, &new_e2_2, 0), _fx_catch_37);
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e1_3, &v_64, 0), _fx_catch_37);
            FX_COPY_PTR(v_64.t0, &etyp1_4);
            _fx_R10Ast__loc_t eloc1_3 = v_64.t1;
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e2_2, &v_65, 0), _fx_catch_37);
            FX_COPY_PTR(v_65.t0, &etyp2_1);
            _fx_R10Ast__loc_t eloc2_2 = v_65.t1;
            if (FX_REC_VARIANT_TAG(new_e2_2) == 6) {
               _fx_N10Ast__exp_t v_69 = 0;
               fx_str_t slit_25 = FX_MAKE_STR("the compared elements must have the same type");
               FX_CALL(
                  _fx_M13Ast_typecheckFM22try_unify_with_literalN10Ast__exp_t3N10Ast__typ_tN10Ast__exp_tS(etyp1_4, new_e2_2,
                     &slit_25, &v_69, 0), _fx_catch_25);
               _fx_make_Ta2N10Ast__exp_t(new_e1_3, v_69, &v_66);

            _fx_catch_25: ;
               if (v_69) {
                  _fx_free_N10Ast__exp_t(&v_69);
               }
            }
            else if (FX_REC_VARIANT_TAG(new_e1_3) == 6) {
               _fx_N10Ast__exp_t v_70 = 0;
               fx_str_t slit_26 = FX_MAKE_STR("the compared elements must have the same type");
               FX_CALL(
                  _fx_M13Ast_typecheckFM22try_unify_with_literalN10Ast__exp_t3N10Ast__typ_tN10Ast__exp_tS(etyp2_1, new_e1_3,
                     &slit_26, &v_70, 0), _fx_catch_26);
               _fx_make_Ta2N10Ast__exp_t(v_70, new_e2_2, &v_66);

            _fx_catch_26: ;
               if (v_70) {
                  _fx_free_N10Ast__exp_t(&v_70);
               }
            }
            else {
               fx_str_t slit_27 = FX_MAKE_STR("the compared elements must have the same type");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp1_4, etyp2_1, &eloc_0, &slit_27,
                     0), _fx_catch_27);
               _fx_make_Ta2N10Ast__exp_t(new_e1_3, new_e2_2, &v_66);

            _fx_catch_27: ;
            }
            FX_CHECK_EXN(_fx_catch_37);
            FX_COPY_PTR(v_66.t0, &new_e1_4);
            FX_COPY_PTR(v_66.t1, &new_e2_3);
            FX_CALL(_fx_M3AstFM6stringS1N13Ast__binary_t(bop_0, &v_67, 0), _fx_catch_37);
            fx_str_t slit_28 = FX_MAKE_STR("result of comparison operation \'");
            fx_str_t slit_29 = FX_MAKE_STR("\' must be bool");
            {
               const fx_str_t strs_4[] = { slit_28, v_67, slit_29 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_4, 3, &v_68), _fx_catch_37);
            }
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, _fx_g22Ast_typecheck__TypBool,
                  &eloc_0, &v_68, 0), _fx_catch_37);
            bool v_71;
            bool res_5;
            FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(etyp1_4, &res_5, 0), _fx_catch_37);
            if (res_5) {
               FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(etyp2_1, &v_71, 0), _fx_catch_37);
            }
            else {
               v_71 = false;
            }
            if (v_71) {
               FX_CALL(
                  _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(bop_0,
                     new_e1_4, new_e2_3, &ctx_0, &result_12), _fx_catch_37);
               _fx_free_N10Ast__exp_t(&result_0);
               FX_COPY_PTR(result_12, &result_0);
               FX_BREAK(_fx_catch_37);
            }
            else {
               int tag_1 = bop_0->u.OpCmp.tag;
               bool res_6;
               if (tag_1 == 1) {
                  res_6 = true;
               }
               else if (tag_1 == 2) {
                  res_6 = true;
               }
               else {
                  res_6 = false;
               }
               FX_CHECK_EXN(_fx_catch_37);
               if (res_6) {
                  _fx_N10Ast__typ_t v_72 = 0;
                  FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp1_4, &v_72, 0), _fx_catch_34);
                  int tag_2 = FX_REC_VARIANT_TAG(v_72);
                  if (tag_2 == 15) {
                     bool res_7;
                     if (FX_REC_VARIANT_TAG(new_e2_3) == 6) {
                        if (new_e2_3->u.ExpLit.t0.tag == 8) {
                           res_7 = true; goto _fx_endmatch_1;
                        }
                     }
                     if (FX_REC_VARIANT_TAG(new_e1_4) == 6) {
                        if (new_e1_4->u.ExpLit.t0.tag == 8) {
                           res_7 = true; goto _fx_endmatch_1;
                        }
                     }
                     res_7 = false;

                  _fx_endmatch_1: ;
                     FX_CHECK_EXN(_fx_catch_29);
                     if (res_7) {
                        _fx_N10Ast__exp_t v_73 = 0;
                        FX_CALL(
                           _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                              bop_0, new_e1_4, new_e2_3, &ctx_0, &v_73), _fx_catch_28);
                        FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(v_73, &result_exp_opt_0),
                           _fx_catch_28);

                     _fx_catch_28: ;
                        if (v_73) {
                           _fx_free_N10Ast__exp_t(&v_73);
                        }
                        goto _fx_endmatch_2;
                     }
                     FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, &result_exp_opt_0);

                  _fx_endmatch_2: ;
                     FX_CHECK_EXN(_fx_catch_29);

                  _fx_catch_29: ;
                  }
                  else if (tag_2 == 10) {
                     if (FX_REC_VARIANT_TAG(new_e2_3) == 6) {
                        _fx_N10Ast__lit_t* v_74 = &new_e2_3->u.ExpLit.t0;
                        if (v_74->tag == 5) {
                           fx_str_t slit_30 = FX_MAKE_STR("");
                           if (fx_streq(&v_74->u.LitString, &slit_30)) {
                              _fx_LN10Ast__exp_t v_75 = 0;
                              _fx_T2N10Ast__typ_tR10Ast__loc_t v_76 = {0};
                              _fx_N10Ast__exp_t e1_size_0 = 0;
                              _fx_N10Ast__lit_t v_77 = {0};
                              _fx_T2N10Ast__typ_tR10Ast__loc_t v_78 = {0};
                              _fx_N10Ast__exp_t v_79 = 0;
                              _fx_N10Ast__exp_t v_80 = 0;
                              FX_CALL(_fx_cons_LN10Ast__exp_t(new_e1_4, 0, true, &v_75), _fx_catch_30);
                              _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &eloc1_3, &v_76);
                              FX_CALL(
                                 _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    &_fx_g28Ast_typecheck__IntrinGetSize, v_75, &v_76, &e1_size_0), _fx_catch_30);
                              _fx_M3AstFM6LitIntN10Ast__lit_t1l(0LL, &v_77);
                              _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &eloc2_2, &v_78);
                              FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_77, &v_78, &v_79),
                                 _fx_catch_30);
                              FX_CALL(
                                 _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    bop_0, e1_size_0, v_79, &ctx_0, &v_80), _fx_catch_30);
                              FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(v_80, &result_exp_opt_0),
                                 _fx_catch_30);

                           _fx_catch_30: ;
                              if (v_80) {
                                 _fx_free_N10Ast__exp_t(&v_80);
                              }
                              if (v_79) {
                                 _fx_free_N10Ast__exp_t(&v_79);
                              }
                              _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_78);
                              _fx_free_N10Ast__lit_t(&v_77);
                              if (e1_size_0) {
                                 _fx_free_N10Ast__exp_t(&e1_size_0);
                              }
                              _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_76);
                              if (v_75) {
                                 _fx_free_LN10Ast__exp_t(&v_75);
                              }
                              goto _fx_endmatch_3;
                           }
                        }
                     }
                     if (FX_REC_VARIANT_TAG(new_e1_4) == 6) {
                        _fx_N10Ast__lit_t* v_81 = &new_e1_4->u.ExpLit.t0;
                        if (v_81->tag == 5) {
                           fx_str_t slit_31 = FX_MAKE_STR("");
                           if (fx_streq(&v_81->u.LitString, &slit_31)) {
                              _fx_LN10Ast__exp_t v_82 = 0;
                              _fx_T2N10Ast__typ_tR10Ast__loc_t v_83 = {0};
                              _fx_N10Ast__exp_t e2_size_0 = 0;
                              _fx_N10Ast__lit_t v_84 = {0};
                              _fx_T2N10Ast__typ_tR10Ast__loc_t v_85 = {0};
                              _fx_N10Ast__exp_t v_86 = 0;
                              _fx_N10Ast__exp_t v_87 = 0;
                              FX_CALL(_fx_cons_LN10Ast__exp_t(new_e2_3, 0, true, &v_82), _fx_catch_31);
                              _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &eloc2_2, &v_83);
                              FX_CALL(
                                 _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    &_fx_g28Ast_typecheck__IntrinGetSize, v_82, &v_83, &e2_size_0), _fx_catch_31);
                              _fx_M3AstFM6LitIntN10Ast__lit_t1l(0LL, &v_84);
                              _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &eloc1_3, &v_85);
                              FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_84, &v_85, &v_86),
                                 _fx_catch_31);
                              FX_CALL(
                                 _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    bop_0, e2_size_0, v_86, &ctx_0, &v_87), _fx_catch_31);
                              FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(v_87, &result_exp_opt_0),
                                 _fx_catch_31);

                           _fx_catch_31: ;
                              if (v_87) {
                                 _fx_free_N10Ast__exp_t(&v_87);
                              }
                              if (v_86) {
                                 _fx_free_N10Ast__exp_t(&v_86);
                              }
                              _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_85);
                              _fx_free_N10Ast__lit_t(&v_84);
                              if (e2_size_0) {
                                 _fx_free_N10Ast__exp_t(&e2_size_0);
                              }
                              _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_83);
                              if (v_82) {
                                 _fx_free_LN10Ast__exp_t(&v_82);
                              }
                              goto _fx_endmatch_3;
                           }
                        }
                     }
                     FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, &result_exp_opt_0);

                  _fx_endmatch_3: ;
                     FX_CHECK_EXN(_fx_catch_32);

                  _fx_catch_32: ;
                  }
                  else if (tag_2 == 24) {
                     _fx_LN10Ast__exp_t v_88 = 0;
                     _fx_T2N10Ast__typ_tR10Ast__loc_t v_89 = {0};
                     _fx_N10Ast__exp_t tag1_0 = 0;
                     _fx_LN10Ast__exp_t v_90 = 0;
                     _fx_T2N10Ast__typ_tR10Ast__loc_t v_91 = {0};
                     _fx_N10Ast__exp_t tag2_0 = 0;
                     _fx_N10Ast__exp_t v_92 = 0;
                     bool v_93;
                     bool res_8;
                     FX_CALL(_fx_M13Ast_typecheckFM14is_simple_ctorB1N10Ast__exp_t(new_e1_4, &res_8, 0), _fx_catch_33);
                     if (res_8) {
                        v_93 = true;
                     }
                     else {
                        FX_CALL(_fx_M13Ast_typecheckFM14is_simple_ctorB1N10Ast__exp_t(new_e2_3, &v_93, 0), _fx_catch_33);
                     }
                     if (v_93) {
                        FX_CALL(_fx_cons_LN10Ast__exp_t(new_e1_4, 0, true, &v_88), _fx_catch_33);
                        _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &eloc1_3, &v_89);
                        FX_CALL(
                           _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                              &_fx_g31Ast_typecheck__IntrinVariantTag, v_88, &v_89, &tag1_0), _fx_catch_33);
                        FX_CALL(_fx_cons_LN10Ast__exp_t(new_e2_3, 0, true, &v_90), _fx_catch_33);
                        _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &eloc2_2, &v_91);
                        FX_CALL(
                           _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                              &_fx_g31Ast_typecheck__IntrinVariantTag, v_90, &v_91, &tag2_0), _fx_catch_33);
                        FX_CALL(
                           _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                              bop_0, tag1_0, tag2_0, &ctx_0, &v_92), _fx_catch_33);
                        FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(v_92, &result_exp_opt_0),
                           _fx_catch_33);
                     }
                     else {
                        FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, &result_exp_opt_0);
                     }

                  _fx_catch_33: ;
                     if (v_92) {
                        _fx_free_N10Ast__exp_t(&v_92);
                     }
                     if (tag2_0) {
                        _fx_free_N10Ast__exp_t(&tag2_0);
                     }
                     _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_91);
                     if (v_90) {
                        _fx_free_LN10Ast__exp_t(&v_90);
                     }
                     if (tag1_0) {
                        _fx_free_N10Ast__exp_t(&tag1_0);
                     }
                     _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_89);
                     if (v_88) {
                        _fx_free_LN10Ast__exp_t(&v_88);
                     }
                  }
                  else {
                     FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, &result_exp_opt_0);
                  }
                  FX_CHECK_EXN(_fx_catch_34);

               _fx_catch_34: ;
                  if (v_72) {
                     _fx_free_N10Ast__typ_t(&v_72);
                  }
                  goto _fx_endmatch_4;
               }
               FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, &result_exp_opt_0);

            _fx_endmatch_4: ;
               FX_CHECK_EXN(_fx_catch_37);
               if ((result_exp_opt_0 != 0) + 1 == 2) {
                  _fx_N10Ast__exp_t* result_13 = &result_exp_opt_0->u.Some;
                  _fx_free_N10Ast__exp_t(&result_0);
                  FX_COPY_PTR(*result_13, &result_0);
                  FX_BREAK(_fx_catch_35);

               _fx_catch_35: ;
               }
               else {
                  _fx_LN10Ast__exp_t v_94 = 0;
                  _fx_N10Ast__exp_t result_14 = 0;
                  _fx_R9Ast__id_t f_id_0;
                  FX_CALL(_fx_M3AstFM16get_binary_fnameRM4id_t2N13Ast__binary_tRM5loc_t(bop_0, &eloc_0, &f_id_0, 0),
                     _fx_catch_36);
                  FX_CALL(_fx_cons_LN10Ast__exp_t(new_e2_3, 0, true, &v_94), _fx_catch_36);
                  FX_CALL(_fx_cons_LN10Ast__exp_t(new_e1_4, v_94, false, &v_94), _fx_catch_36);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM19check_and_make_callN10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
                        &f_id_0, v_94, &ctx_0, &eloc_0, &env_2, etyp_0, sc_2, &result_14, 0), _fx_catch_36);
                  _fx_free_N10Ast__exp_t(&result_0);
                  FX_COPY_PTR(result_14, &result_0);
                  FX_BREAK(_fx_catch_36);

               _fx_catch_36: ;
                  if (result_14) {
                     _fx_free_N10Ast__exp_t(&result_14);
                  }
                  if (v_94) {
                     _fx_free_LN10Ast__exp_t(&v_94);
                  }
               }
               FX_CHECK_EXN(_fx_catch_37);
            }

         _fx_catch_37: ;
            if (result_exp_opt_0) {
               _fx_free_Nt6option1N10Ast__exp_t(&result_exp_opt_0);
            }
            if (result_12) {
               _fx_free_N10Ast__exp_t(&result_12);
            }
            FX_FREE_STR(&v_68);
            FX_FREE_STR(&v_67);
            if (new_e2_3) {
               _fx_free_N10Ast__exp_t(&new_e2_3);
            }
            if (new_e1_4) {
               _fx_free_N10Ast__exp_t(&new_e1_4);
            }
            _fx_free_Ta2N10Ast__exp_t(&v_66);
            if (etyp2_1) {
               _fx_free_N10Ast__typ_t(&etyp2_1);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_65);
            if (etyp1_4) {
               _fx_free_N10Ast__typ_t(&etyp1_4);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_64);
            if (new_e2_2) {
               _fx_free_N10Ast__exp_t(&new_e2_2);
            }
            if (new_e1_3) {
               _fx_free_N10Ast__exp_t(&new_e1_3);
            }
            goto _fx_endmatch_41;
         }
      }
      if (tag_0 == 8) {
         _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_7 = &e_2->u.ExpBinary;
         _fx_N13Ast__binary_t aug_op_0 = vcase_7->t0;
         if (FX_REC_VARIANT_TAG(aug_op_0) == 27) {
            _fx_N13Ast__binary_t bop_1 = aug_op_0->u.OpAugBinary;
            int tag_3 = FX_REC_VARIANT_TAG(bop_1);
            bool res_9;
            if (tag_3 == 1) {
               res_9 = true;
            }
            else if (tag_3 == 2) {
               res_9 = true;
            }
            else if (tag_3 == 3) {
               res_9 = true;
            }
            else if (tag_3 == 4) {
               res_9 = true;
            }
            else if (tag_3 == 6) {
               res_9 = true;
            }
            else if (tag_3 == 18) {
               res_9 = true;
            }
            else if (tag_3 == 20) {
               res_9 = true;
            }
            else if (tag_3 == 16) {
               res_9 = true;
            }
            else if (tag_3 == 12) {
               res_9 = true;
            }
            else if (tag_3 == 13) {
               res_9 = true;
            }
            else if (tag_3 == 14) {
               res_9 = true;
            }
            else if (tag_3 == 8) {
               res_9 = true;
            }
            else if (tag_3 == 9) {
               res_9 = true;
            }
            else {
               res_9 = false;
            }
            FX_CHECK_EXN(_fx_catch_43);
            if (res_9) {
               _fx_N10Ast__exp_t new_e1_5 = 0;
               _fx_T2N10Ast__typ_tR10Ast__loc_t ectx1_0 = {0};
               _fx_N10Ast__typ_t etyp1_5 = 0;
               _fx_N10Ast__exp_t new_e2_4 = 0;
               _fx_N10Ast__typ_t v_95 = 0;
               _fx_Nt6option1N10Ast__exp_t probably_result_0 = 0;
               _fx_LN10Ast__exp_t v_96 = 0;
               fx_str_t v_97 = {0};
               fx_str_t v_98 = {0};
               fx_exn_t v_99 = {0};
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     vcase_7->t1, &env_2, sc_2, &new_e1_5, 0), _fx_catch_41);
               FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e1_5, &ectx1_0, 0), _fx_catch_41);
               FX_COPY_PTR(ectx1_0.t0, &etyp1_5);
               _fx_R10Ast__loc_t eloc1_4 = ectx1_0.t1;
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     vcase_7->t2, &env_2, sc_2, &new_e2_4, 0), _fx_catch_41);
               FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp1_5, &v_95, 0), _fx_catch_41);
               int tag_4 = FX_REC_VARIANT_TAG(v_95);
               bool is_appropriate_type_0;
               bool res_10;
               if (tag_4 == 19) {
                  res_10 = true;
               }
               else if (tag_4 == 20) {
                  res_10 = true;
               }
               else {
                  res_10 = false;
               }
               FX_CHECK_EXN(_fx_catch_41);
               if (res_10) {
                  is_appropriate_type_0 = true; goto _fx_endmatch_6;
               }
               if (tag_4 == 24) {
                  _fx_N14Ast__id_info_t v_100 = {0};
                  FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&v_95->u.TypApp.t1, &eloc1_4, &v_100, 0),
                     _fx_catch_38);
                  int tag_5 = v_100.tag;
                  bool res_11;
                  if (tag_5 == 5) {
                     res_11 = true;
                  }
                  else if (tag_5 == 6) {
                     res_11 = true;
                  }
                  else if (tag_5 == 7) {
                     res_11 = true;
                  }
                  else {
                     res_11 = false;
                  }
                  FX_CHECK_EXN(_fx_catch_38);
                  if (res_11) {
                     is_appropriate_type_0 = true; goto _fx_endmatch_5;
                  }
                  is_appropriate_type_0 = false;

               _fx_endmatch_5: ;
                  FX_CHECK_EXN(_fx_catch_38);

               _fx_catch_38: ;
                  _fx_free_N14Ast__id_info_t(&v_100);
                  goto _fx_endmatch_6;
               }
               is_appropriate_type_0 = false;

            _fx_endmatch_6: ;
               FX_CHECK_EXN(_fx_catch_41);
               if (is_appropriate_type_0) {
                  _fx_R9Ast__id_t f_id_1;
                  FX_CALL(_fx_M3AstFM16get_binary_fnameRM4id_t2N13Ast__binary_tRM5loc_t(aug_op_0, &eloc_0, &f_id_1, 0),
                     _fx_catch_41);
                  FX_CALL(_fx_cons_LN10Ast__exp_t(new_e2_4, 0, true, &v_96), _fx_catch_41);
                  FX_CALL(_fx_cons_LN10Ast__exp_t(new_e1_5, v_96, false, &v_96), _fx_catch_41);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM15maybe_make_callNt6option1N10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
                        &f_id_1, v_96, &ctx_0, &eloc_0, &env_2, etyp_0, sc_2, &probably_result_0, 0), _fx_catch_41);
               }
               else {
                  FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, &probably_result_0);
               }
               bool v_101;
               FX_CALL(
                  _fx_M13Ast_typecheckFM9is_lvalueB4BN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_t(true, new_e1_5,
                     &ectx1_0, &eloc_0, &v_101, 0), _fx_catch_41);
               if (!v_101) {
                  FX_CALL(_fx_M3AstFM6stringS1N13Ast__binary_t(aug_op_0, &v_97, 0), _fx_catch_41);
                  fx_str_t slit_32 = FX_MAKE_STR("the left side of augmented operation ");
                  fx_str_t slit_33 = FX_MAKE_STR(" is not an l-value");
                  {
                     const fx_str_t strs_5[] = { slit_32, v_97, slit_33 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_5, 3, &v_98), _fx_catch_41);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc1_4, &v_98, &v_99, 0), _fx_catch_41);
                  FX_THROW(&v_99, false, _fx_catch_41);
               }
               if ((probably_result_0 != 0) + 1 == 2) {
                  _fx_N10Ast__exp_t* result_15 = &probably_result_0->u.Some;
                  _fx_free_N10Ast__exp_t(&result_0);
                  FX_COPY_PTR(*result_15, &result_0);
                  FX_BREAK(_fx_catch_39);

               _fx_catch_39: ;
               }
               else {
                  _fx_rNt6option1N10Ast__typ_t v_102 = 0;
                  _fx_N10Ast__typ_t v_103 = 0;
                  _fx_T2N10Ast__typ_tR10Ast__loc_t v_104 = {0};
                  _fx_N10Ast__exp_t v_105 = 0;
                  _fx_N10Ast__exp_t binres_0 = 0;
                  _fx_N10Ast__exp_t v_106 = 0;
                  FX_CALL(_fx_make_rNt6option1N10Ast__typ_t(_fx_g22Ast_typecheck__None11_, &v_102), _fx_catch_40);
                  FX_CALL(_fx_M3AstFM6TypVarN10Ast__typ_t1rNt6option1N10Ast__typ_t(v_102, &v_103), _fx_catch_40);
                  _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_103, &eloc_0, &v_104);
                  FX_CALL(
                     _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(bop_1,
                        new_e1_5, new_e2_4, &v_104, &v_105), _fx_catch_40);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                        v_105, &env_2, sc_2, &binres_0, 0), _fx_catch_40);
                  FX_CALL(
                     _fx_M3AstFM9ExpAssignN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tRM5loc_t(new_e1_5, binres_0, &eloc_0, &v_106),
                     _fx_catch_40);
                  _fx_free_N10Ast__exp_t(&e_1);
                  FX_COPY_PTR(v_106, &e_1);
                  _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
                  _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &env_1);
                  FX_FREE_LIST_SIMPLE(&sc_1);
                  FX_COPY_PTR(sc_2, &sc_1);

               _fx_catch_40: ;
                  if (v_106) {
                     _fx_free_N10Ast__exp_t(&v_106);
                  }
                  if (binres_0) {
                     _fx_free_N10Ast__exp_t(&binres_0);
                  }
                  if (v_105) {
                     _fx_free_N10Ast__exp_t(&v_105);
                  }
                  _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_104);
                  if (v_103) {
                     _fx_free_N10Ast__typ_t(&v_103);
                  }
                  if (v_102) {
                     _fx_free_rNt6option1N10Ast__typ_t(&v_102);
                  }
               }
               FX_CHECK_EXN(_fx_catch_41);

            _fx_catch_41: ;
               fx_free_exn(&v_99);
               FX_FREE_STR(&v_98);
               FX_FREE_STR(&v_97);
               if (v_96) {
                  _fx_free_LN10Ast__exp_t(&v_96);
               }
               if (probably_result_0) {
                  _fx_free_Nt6option1N10Ast__exp_t(&probably_result_0);
               }
               if (v_95) {
                  _fx_free_N10Ast__typ_t(&v_95);
               }
               if (new_e2_4) {
                  _fx_free_N10Ast__exp_t(&new_e2_4);
               }
               if (etyp1_5) {
                  _fx_free_N10Ast__typ_t(&etyp1_5);
               }
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&ectx1_0);
               if (new_e1_5) {
                  _fx_free_N10Ast__exp_t(&new_e1_5);
               }
               goto _fx_endmatch_7;
            }
            fx_str_t v_107 = {0};
            fx_str_t v_108 = {0};
            fx_exn_t v_109 = {0};
            FX_CALL(_fx_M3AstFM6stringS1N13Ast__binary_t(bop_1, &v_107, 0), _fx_catch_42);
            fx_str_t slit_34 = FX_MAKE_STR("unsupported augmented binary operation ");
            {
               const fx_str_t strs_6[] = { slit_34, v_107 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_6, 2, &v_108), _fx_catch_42);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_108, &v_109, 0), _fx_catch_42);
            FX_THROW(&v_109, false, _fx_catch_42);

         _fx_catch_42: ;
            fx_free_exn(&v_109);
            FX_FREE_STR(&v_108);
            FX_FREE_STR(&v_107);

         _fx_endmatch_7: ;
            FX_CHECK_EXN(_fx_catch_43);

         _fx_catch_43: ;
            goto _fx_endmatch_41;
         }
      }
      if (tag_0 == 8) {
         _fx_N10Ast__exp_t new_e1_6 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_110 = {0};
         _fx_N10Ast__typ_t etyp1_6 = 0;
         _fx_N10Ast__exp_t new_e2_5 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_111 = {0};
         _fx_N10Ast__typ_t etyp2_2 = 0;
         _fx_N13Ast__binary_t bop_wo_dot_0 = 0;
         _fx_T2N13Ast__binary_tNt6option1N10Ast__typ_t v_112 = {0};
         _fx_N13Ast__binary_t bop_2 = 0;
         _fx_Nt6option1N10Ast__typ_t typ_opt_0 = 0;
         _fx_N10Ast__typ_t v_113 = 0;
         _fx_N10Ast__typ_t v_114 = 0;
         _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_8 = &e_2->u.ExpBinary;
         _fx_N10Ast__exp_t e2_2 = vcase_8->t2;
         _fx_N10Ast__exp_t e1_0 = vcase_8->t1;
         _fx_N13Ast__binary_t bop_3 = vcase_8->t0;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e1_0, &env_2, sc_2, &new_e1_6, 0), _fx_catch_61);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e1_6, &v_110, 0), _fx_catch_61);
         FX_COPY_PTR(v_110.t0, &etyp1_6);
         _fx_R10Ast__loc_t eloc1_5 = v_110.t1;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e2_2, &env_2, sc_2, &new_e2_5, 0), _fx_catch_61);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e2_5, &v_111, 0), _fx_catch_61);
         FX_COPY_PTR(v_111.t0, &etyp2_2);
         _fx_R10Ast__loc_t eloc2_3 = v_111.t1;
         FX_CALL(_fx_M3AstFM21binary_try_remove_dotN13Ast__binary_t1N13Ast__binary_t(bop_3, &bop_wo_dot_0, 0), _fx_catch_61);
         int tag_6 = FX_REC_VARIANT_TAG(bop_3);
         bool res_12;
         if (tag_6 == 1) {
            res_12 = true;
         }
         else if (tag_6 == 2) {
            res_12 = true;
         }
         else if (tag_6 == 3) {
            res_12 = true;
         }
         else if (tag_6 == 4) {
            res_12 = true;
         }
         else if (tag_6 == 6) {
            res_12 = true;
         }
         else if (tag_6 == 7) {
            res_12 = true;
         }
         else if (tag_6 == 8) {
            res_12 = true;
         }
         else if (tag_6 == 9) {
            res_12 = true;
         }
         else {
            res_12 = false;
         }
         FX_CHECK_EXN(_fx_catch_61);
         if (res_12) {
            _fx_Nt6option1N10Ast__typ_t typ_opt_1 = 0;
            bool is_shift_0;
            if (FX_REC_VARIANT_TAG(bop_3) == 8) {
               is_shift_0 = true;
            }
            else {
               is_shift_0 = FX_REC_VARIANT_TAG(bop_3) == 9;
            }
            bool allow_fp_0 = !is_shift_0;
            FX_CALL(
               _fx_M13Ast_typecheckFM12coerce_typesNt6option1N10Ast__typ_t6N10Ast__typ_tN10Ast__typ_tBBBR10Ast__loc_t(etyp1_6,
                  etyp2_2, false, allow_fp_0, is_shift_0, &eloc_0, &typ_opt_1, 0), _fx_catch_44);
            _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_3, typ_opt_1, &v_112);

         _fx_catch_44: ;
            if (typ_opt_1) {
               _fx_free_Nt6option1N10Ast__typ_t(&typ_opt_1);
            }
            goto _fx_endmatch_10;
         }
         bool res_13;
         if (tag_6 == 10) {
            res_13 = true;
         }
         else if (tag_6 == 11) {
            res_13 = true;
         }
         else if (tag_6 == 12) {
            res_13 = true;
         }
         else if (tag_6 == 13) {
            res_13 = true;
         }
         else if (tag_6 == 14) {
            res_13 = true;
         }
         else if (tag_6 == 15) {
            res_13 = true;
         }
         else {
            res_13 = false;
         }
         FX_CHECK_EXN(_fx_catch_61);
         if (res_13) {
            _fx_Nt6option1N10Ast__typ_t typ_opt_2 = 0;
            FX_CALL(
               _fx_M13Ast_typecheckFM12coerce_typesNt6option1N10Ast__typ_t6N10Ast__typ_tN10Ast__typ_tBBBR10Ast__loc_t(etyp1_6,
                  etyp2_2, false, true, false, &eloc_0, &typ_opt_2, 0), _fx_catch_45);
            if ((typ_opt_2 != 0) + 1 == 2) {
               _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_wo_dot_0, typ_opt_2, &v_112);
            }
            else {
               _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_3, typ_opt_2, &v_112);
            }
            FX_CHECK_EXN(_fx_catch_45);

         _fx_catch_45: ;
            if (typ_opt_2) {
               _fx_free_Nt6option1N10Ast__typ_t(&typ_opt_2);
            }
            goto _fx_endmatch_10;
         }
         bool res_14;
         if (tag_6 == 16) {
            res_14 = true;
         }
         else if (tag_6 == 18) {
            res_14 = true;
         }
         else if (tag_6 == 20) {
            res_14 = true;
         }
         else {
            res_14 = false;
         }
         FX_CHECK_EXN(_fx_catch_61);
         if (res_14) {
            _fx_N10Ast__typ_t v_115 = 0;
            _fx_N10Ast__typ_t v_116 = 0;
            _fx_Nt6option1N10Ast__typ_t typ_opt_3 = 0;
            FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp1_6, &v_115, 0), _fx_catch_50);
            FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp2_2, &v_116, 0), _fx_catch_50);
            if (FX_REC_VARIANT_TAG(v_115) == 5) {
               if (FX_REC_VARIANT_TAG(v_116) == 5) {
                  FX_CALL(
                     _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, &typ_opt_3),
                     _fx_catch_46);

               _fx_catch_46: ;
                  goto _fx_endmatch_8;
               }
            }
            if (FX_REC_VARIANT_TAG(v_116) == 6) {
               if (FX_REC_VARIANT_TAG(v_115) == 6) {
                  int_ b1_0 = v_115->u.TypSInt;
                  if (b1_0 == v_116->u.TypSInt) {
                     _fx_N10Ast__typ_t v_117 = 0;
                     FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(b1_0, &v_117), _fx_catch_47);
                     FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(v_117, &typ_opt_3), _fx_catch_47);

                  _fx_catch_47: ;
                     if (v_117) {
                        _fx_free_N10Ast__typ_t(&v_117);
                     }
                     goto _fx_endmatch_8;
                  }
               }
            }
            if (FX_REC_VARIANT_TAG(v_116) == 7) {
               if (FX_REC_VARIANT_TAG(v_115) == 7) {
                  int_ b1_1 = v_115->u.TypUInt;
                  if (b1_1 == v_116->u.TypUInt) {
                     _fx_N10Ast__typ_t v_118 = 0;
                     FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(b1_1, &v_118), _fx_catch_48);
                     FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(v_118, &typ_opt_3), _fx_catch_48);

                  _fx_catch_48: ;
                     if (v_118) {
                        _fx_free_N10Ast__typ_t(&v_118);
                     }
                     goto _fx_endmatch_8;
                  }
               }
            }
            if (FX_REC_VARIANT_TAG(v_115) == 12) {
               if (FX_REC_VARIANT_TAG(v_116) == 12) {
                  FX_CALL(
                     _fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(_fx_g22Ast_typecheck__TypBool,
                        &typ_opt_3), _fx_catch_49);

               _fx_catch_49: ;
                  goto _fx_endmatch_8;
               }
            }
            FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, &typ_opt_3);

         _fx_endmatch_8: ;
            FX_CHECK_EXN(_fx_catch_50);
            _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_3, typ_opt_3, &v_112);

         _fx_catch_50: ;
            if (typ_opt_3) {
               _fx_free_Nt6option1N10Ast__typ_t(&typ_opt_3);
            }
            if (v_116) {
               _fx_free_N10Ast__typ_t(&v_116);
            }
            if (v_115) {
               _fx_free_N10Ast__typ_t(&v_115);
            }
            goto _fx_endmatch_10;
         }
         bool res_15;
         if (tag_6 == 17) {
            res_15 = true;
         }
         else if (tag_6 == 19) {
            res_15 = true;
         }
         else {
            res_15 = false;
         }
         FX_CHECK_EXN(_fx_catch_61);
         if (res_15) {
            _fx_Nt6option1N10Ast__typ_t v_119 = 0;
            fx_str_t slit_35 = FX_MAKE_STR("arguments of logical operation must be boolean");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp1_6, _fx_g22Ast_typecheck__TypBool,
                  &eloc1_5, &slit_35, 0), _fx_catch_51);
            fx_str_t slit_36 = FX_MAKE_STR("arguments of logical operation must be boolean");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp2_2, _fx_g22Ast_typecheck__TypBool,
                  &eloc2_3, &slit_36, 0), _fx_catch_51);
            FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(_fx_g22Ast_typecheck__TypBool, &v_119),
               _fx_catch_51);
            _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_3, v_119, &v_112);

         _fx_catch_51: ;
            if (v_119) {
               _fx_free_Nt6option1N10Ast__typ_t(&v_119);
            }
            goto _fx_endmatch_10;
         }
         if (tag_6 == 22) {
            _fx_Nt6option1N10Ast__typ_t v_120 = 0;
            bool v_121;
            bool res_16;
            FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(etyp1_6, &res_16, 0), _fx_catch_52);
            if (res_16) {
               FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(etyp2_2, &v_121, 0), _fx_catch_52);
            }
            else {
               v_121 = false;
            }
            if (v_121) {
               FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(_fx_g22Ast_typecheck__TypBool, &v_120),
                  _fx_catch_52);
               _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_wo_dot_0, v_120, &v_112);
            }
            else if (FX_REC_VARIANT_TAG(etyp1_6) == 10) {
               _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_wo_dot_0, _fx_g22Ast_typecheck__None11_, &v_112);
            }
            else {
               _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_3, _fx_g22Ast_typecheck__None11_, &v_112);
            }

         _fx_catch_52: ;
            if (v_120) {
               _fx_free_Nt6option1N10Ast__typ_t(&v_120);
            }
            goto _fx_endmatch_10;
         }
         bool res_17;
         if (tag_6 == 23) {
            res_17 = true;
         }
         else if (tag_6 == 24) {
            res_17 = true;
         }
         else {
            res_17 = false;
         }
         FX_CHECK_EXN(_fx_catch_61);
         if (res_17) {
            _fx_N10Ast__typ_t v_122 = 0;
            _fx_N10Ast__typ_t v_123 = 0;
            bool v_124;
            bool res_18;
            FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(etyp1_6, &res_18, 0), _fx_catch_53);
            if (res_18) {
               FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(etyp2_2, &v_124, 0), _fx_catch_53);
            }
            else {
               v_124 = false;
            }
            if (v_124) {
               _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_wo_dot_0, _fx_g22Ast_typecheck__None11_, &v_112);
            }
            else {
               FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp1_6, &v_122, 0), _fx_catch_53);
               FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp2_2, &v_123, 0), _fx_catch_53);
               if (FX_REC_VARIANT_TAG(v_122) == 10) {
                  if (FX_REC_VARIANT_TAG(v_123) == 10) {
                     _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_wo_dot_0, _fx_g22Ast_typecheck__None11_, &v_112);
                     goto _fx_endmatch_9;
                  }
               }
               _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_3, _fx_g22Ast_typecheck__None11_, &v_112);

            _fx_endmatch_9: ;
               FX_CHECK_EXN(_fx_catch_53);
            }

         _fx_catch_53: ;
            if (v_123) {
               _fx_free_N10Ast__typ_t(&v_123);
            }
            if (v_122) {
               _fx_free_N10Ast__typ_t(&v_122);
            }
            goto _fx_endmatch_10;
         }
         if (tag_6 == 25) {
            fx_str_t slit_37 = FX_MAKE_STR("only equal types can be compared for identity");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp1_6, etyp2_2, &eloc_0, &slit_37, 0),
               _fx_catch_54);
            fx_str_t slit_38 = FX_MAKE_STR("the result of identity comparison should be \'bool\'");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, _fx_g22Ast_typecheck__TypBool,
                  &eloc_0, &slit_38, 0), _fx_catch_54);
            _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_3, _fx_g22Ast_typecheck__None11_, &v_112);

         _fx_catch_54: ;
            goto _fx_endmatch_10;
         }
         bool res_19;
         if (tag_6 == 26) {
            res_19 = true;
         }
         else if (tag_6 == 21) {
            res_19 = true;
         }
         else if (tag_6 == 27) {
            res_19 = true;
         }
         else {
            res_19 = false;
         }
         FX_CHECK_EXN(_fx_catch_61);
         if (res_19) {
            fx_str_t v_125 = {0};
            fx_str_t v_126 = {0};
            fx_exn_t v_127 = {0};
            FX_CALL(_fx_M3AstFM6stringS1N13Ast__binary_t(bop_3, &v_125, 0), _fx_catch_55);
            fx_str_t slit_39 = FX_MAKE_STR("unsupported binary operation ");
            {
               const fx_str_t strs_7[] = { slit_39, v_125 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_7, 2, &v_126), _fx_catch_55);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_126, &v_127, 0), _fx_catch_55);
            FX_THROW(&v_127, false, _fx_catch_55);

         _fx_catch_55: ;
            fx_free_exn(&v_127);
            FX_FREE_STR(&v_126);
            FX_FREE_STR(&v_125);
            goto _fx_endmatch_10;
         }
         if (tag_6 == 5) {
            _fx_make_T2N13Ast__binary_tNt6option1N10Ast__typ_t(bop_3, _fx_g22Ast_typecheck__None11_, &v_112);
            goto _fx_endmatch_10;
         }
         FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_61);

      _fx_endmatch_10: ;
         FX_CHECK_EXN(_fx_catch_61);
         FX_COPY_PTR(v_112.t0, &bop_2);
         FX_COPY_PTR(v_112.t1, &typ_opt_0);
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp1_6, &v_113, 0), _fx_catch_61);
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp2_2, &v_114, 0), _fx_catch_61);
         if ((typ_opt_0 != 0) + 1 == 2) {
            _fx_N10Ast__exp_t result_16 = 0;
            fx_str_t slit_40 = FX_MAKE_STR("improper type of the arithmetic operation result");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(typ_opt_0->u.Some, etyp_0, &eloc_0,
                  &slit_40, 0), _fx_catch_56);
            FX_CALL(
               _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(bop_2,
                  new_e1_6, new_e2_5, &ctx_0, &result_16), _fx_catch_56);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_16, &result_0);
            FX_BREAK(_fx_catch_56);

         _fx_catch_56: ;
            if (result_16) {
               _fx_free_N10Ast__exp_t(&result_16);
            }
            goto _fx_endmatch_13;
         }
         bool res_20;
         if (FX_REC_VARIANT_TAG(bop_2) == 1) {
            if (FX_REC_VARIANT_TAG(v_113) == 10) {
               if (FX_REC_VARIANT_TAG(v_114) == 10) {
                  res_20 = true; goto _fx_endmatch_11;
               }
            }
         }
         if (FX_REC_VARIANT_TAG(bop_2) == 1) {
            if (FX_REC_VARIANT_TAG(v_113) == 10) {
               if (FX_REC_VARIANT_TAG(v_114) == 11) {
                  res_20 = true; goto _fx_endmatch_11;
               }
            }
         }
         if (FX_REC_VARIANT_TAG(bop_2) == 1) {
            if (FX_REC_VARIANT_TAG(v_113) == 11) {
               if (FX_REC_VARIANT_TAG(v_114) == 10) {
                  res_20 = true; goto _fx_endmatch_11;
               }
            }
         }
         if (FX_REC_VARIANT_TAG(bop_2) == 1) {
            if (FX_REC_VARIANT_TAG(v_113) == 11) {
               if (FX_REC_VARIANT_TAG(v_114) == 11) {
                  res_20 = true; goto _fx_endmatch_11;
               }
            }
         }
         res_20 = false;

      _fx_endmatch_11: ;
         FX_CHECK_EXN(_fx_catch_61);
         if (res_20) {
            _fx_N10Ast__exp_t result_17 = 0;
            fx_str_t slit_41 = FX_MAKE_STR("improper type of the string concatenation operation (string is expected)");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(_fx_g24Ast_typecheck__TypString, etyp_0,
                  &eloc_0, &slit_41, 0), _fx_catch_57);
            FX_CALL(
               _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(bop_2,
                  new_e1_6, new_e2_5, &ctx_0, &result_17), _fx_catch_57);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_17, &result_0);
            FX_BREAK(_fx_catch_57);

         _fx_catch_57: ;
            if (result_17) {
               _fx_free_N10Ast__exp_t(&result_17);
            }
            goto _fx_endmatch_13;
         }
         bool res_21;
         if (FX_REC_VARIANT_TAG(bop_2) == 1) {
            if (FX_REC_VARIANT_TAG(v_113) == 16) {
               res_21 = true; goto _fx_endmatch_12;
            }
         }
         if (FX_REC_VARIANT_TAG(bop_2) == 1) {
            if (FX_REC_VARIANT_TAG(v_114) == 16) {
               res_21 = true; goto _fx_endmatch_12;
            }
         }
         res_21 = false;

      _fx_endmatch_12: ;
         FX_CHECK_EXN(_fx_catch_61);
         if (res_21) {
            fx_str_t v_128 = {0};
            fx_str_t v_129 = {0};
            fx_str_t v_130 = {0};
            fx_str_t v_131 = {0};
            fx_str_t v_132 = {0};
            fx_str_t v_133 = {0};
            fx_str_t v_134 = {0};
            fx_str_t v_135 = {0};
            fx_str_t v_136 = {0};
            fx_str_t v_137 = {0};
            _fx_N10Ast__exp_t result_18 = 0;
            FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp1_6, &v_128, 0), _fx_catch_58);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_128, &v_129, 0), _fx_catch_58);
            FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp2_2, &v_130, 0), _fx_catch_58);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_130, &v_131, 0), _fx_catch_58);
            fx_str_t slit_42 = FX_MAKE_STR("the two concatenated vectors have different types \'");
            fx_str_t slit_43 = FX_MAKE_STR("\' and \'");
            fx_str_t slit_44 = FX_MAKE_STR("\'");
            {
               const fx_str_t strs_8[] = { slit_42, v_129, slit_43, v_131, slit_44 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_8, 5, &v_132), _fx_catch_58);
            }
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp1_6, etyp2_2, &eloc_0, &v_132, 0),
               _fx_catch_58);
            FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp_0, &v_133, 0), _fx_catch_58);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_133, &v_134, 0), _fx_catch_58);
            FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp1_6, &v_135, 0), _fx_catch_58);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_135, &v_136, 0), _fx_catch_58);
            fx_str_t slit_45 = FX_MAKE_STR("the type of vector concatenation result \'");
            fx_str_t slit_46 = FX_MAKE_STR("\' is different from operands\' type \'");
            fx_str_t slit_47 = FX_MAKE_STR("\'");
            {
               const fx_str_t strs_9[] = { slit_45, v_134, slit_46, v_136, slit_47 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_9, 5, &v_137), _fx_catch_58);
            }
            FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp1_6, etyp_0, &eloc_0, &v_137, 0),
               _fx_catch_58);
            FX_CALL(
               _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(bop_2,
                  new_e1_6, new_e2_5, &ctx_0, &result_18), _fx_catch_58);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_18, &result_0);
            FX_BREAK(_fx_catch_58);

         _fx_catch_58: ;
            if (result_18) {
               _fx_free_N10Ast__exp_t(&result_18);
            }
            FX_FREE_STR(&v_137);
            FX_FREE_STR(&v_136);
            FX_FREE_STR(&v_135);
            FX_FREE_STR(&v_134);
            FX_FREE_STR(&v_133);
            FX_FREE_STR(&v_132);
            FX_FREE_STR(&v_131);
            FX_FREE_STR(&v_130);
            FX_FREE_STR(&v_129);
            FX_FREE_STR(&v_128);
            goto _fx_endmatch_13;
         }
         if (FX_REC_VARIANT_TAG(bop_2) == 1) {
            if (FX_REC_VARIANT_TAG(v_113) == 15) {
               if (FX_REC_VARIANT_TAG(v_114) == 15) {
                  if (FX_REC_VARIANT_TAG(e1_0) == 8) {
                     _fx_T4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_9 = &e1_0->u.ExpBinary;
                     if (FX_REC_VARIANT_TAG(vcase_9->t0) == 1) {
                        _fx_LR10Ast__loc_t v_138 = 0;
                        _fx_N10Ast__typ_t v_139 = 0;
                        _fx_T2N10Ast__typ_tR10Ast__loc_t v_140 = {0};
                        _fx_N10Ast__exp_t e2__0 = 0;
                        _fx_T2N10Ast__typ_tR10Ast__loc_t v_141 = {0};
                        _fx_N10Ast__exp_t v_142 = 0;
                        _fx_N10Ast__exp_t sub_e2_0 = vcase_9->t2;
                        _fx_R10Ast__loc_t sub_e2_loc_0;
                        FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(sub_e2_0, &sub_e2_loc_0, 0), _fx_catch_59);
                        FX_CALL(_fx_cons_LR10Ast__loc_t(&eloc2_3, 0, true, &v_138), _fx_catch_59);
                        FX_CALL(_fx_cons_LR10Ast__loc_t(&sub_e2_loc_0, v_138, false, &v_138), _fx_catch_59);
                        _fx_R10Ast__loc_t e2_loc_0;
                        FX_CALL(_fx_M3AstFM11loclist2locRM5loc_t2LRM5loc_tRM5loc_t(v_138, &eloc2_3, &e2_loc_0, 0),
                           _fx_catch_59);
                        FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_139, 0), _fx_catch_59);
                        _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_139, &e2_loc_0, &v_140);
                        FX_CALL(
                           _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                              _fx_g20Ast_typecheck__OpAdd, sub_e2_0, e2_2, &v_140, &e2__0), _fx_catch_59);
                        _fx_make_T2N10Ast__typ_tR10Ast__loc_t(etyp_0, &eloc_0, &v_141);
                        FX_CALL(
                           _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                              _fx_g20Ast_typecheck__OpAdd, vcase_9->t1, e2__0, &v_141, &v_142), _fx_catch_59);
                        _fx_free_N10Ast__exp_t(&e_1);
                        FX_COPY_PTR(v_142, &e_1);
                        _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
                        _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &env_1);
                        FX_FREE_LIST_SIMPLE(&sc_1);
                        FX_COPY_PTR(sc_2, &sc_1);

                     _fx_catch_59: ;
                        if (v_142) {
                           _fx_free_N10Ast__exp_t(&v_142);
                        }
                        _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_141);
                        if (e2__0) {
                           _fx_free_N10Ast__exp_t(&e2__0);
                        }
                        _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_140);
                        if (v_139) {
                           _fx_free_N10Ast__typ_t(&v_139);
                        }
                        FX_FREE_LIST_SIMPLE(&v_138);
                        goto _fx_endmatch_13;
                     }
                  }
               }
            }
         }
         _fx_LN10Ast__exp_t v_143 = 0;
         _fx_N10Ast__exp_t result_19 = 0;
         _fx_R9Ast__id_t f_id_2;
         FX_CALL(_fx_M3AstFM16get_binary_fnameRM4id_t2N13Ast__binary_tRM5loc_t(bop_2, &eloc_0, &f_id_2, 0), _fx_catch_60);
         FX_CALL(_fx_cons_LN10Ast__exp_t(new_e2_5, 0, true, &v_143), _fx_catch_60);
         FX_CALL(_fx_cons_LN10Ast__exp_t(new_e1_6, v_143, false, &v_143), _fx_catch_60);
         FX_CALL(
            _fx_M13Ast_typecheckFM19check_and_make_callN10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
               &f_id_2, v_143, &ctx_0, &eloc_0, &env_2, etyp_0, sc_2, &result_19, 0), _fx_catch_60);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_19, &result_0);
         FX_BREAK(_fx_catch_60);

      _fx_catch_60: ;
         if (result_19) {
            _fx_free_N10Ast__exp_t(&result_19);
         }
         if (v_143) {
            _fx_free_LN10Ast__exp_t(&v_143);
         }

      _fx_endmatch_13: ;
         FX_CHECK_EXN(_fx_catch_61);

      _fx_catch_61: ;
         if (v_114) {
            _fx_free_N10Ast__typ_t(&v_114);
         }
         if (v_113) {
            _fx_free_N10Ast__typ_t(&v_113);
         }
         if (typ_opt_0) {
            _fx_free_Nt6option1N10Ast__typ_t(&typ_opt_0);
         }
         if (bop_2) {
            _fx_free_N13Ast__binary_t(&bop_2);
         }
         _fx_free_T2N13Ast__binary_tNt6option1N10Ast__typ_t(&v_112);
         if (bop_wo_dot_0) {
            _fx_free_N13Ast__binary_t(&bop_wo_dot_0);
         }
         if (etyp2_2) {
            _fx_free_N10Ast__typ_t(&etyp2_2);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_111);
         if (new_e2_5) {
            _fx_free_N10Ast__exp_t(&new_e2_5);
         }
         if (etyp1_6) {
            _fx_free_N10Ast__typ_t(&etyp1_6);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_110);
         if (new_e1_6) {
            _fx_free_N10Ast__exp_t(&new_e1_6);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 22) {
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_144 = {0};
         _fx_N10Ast__typ_t etyp1_7 = 0;
         _fx_N10Ast__exp_t new_e1_7 = 0;
         _fx_N10Ast__exp_t result_20 = 0;
         _fx_N10Ast__exp_t e1_1 = e_2->u.ExpThrow.t0;
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_1, &v_144, 0), _fx_catch_62);
         FX_COPY_PTR(v_144.t0, &etyp1_7);
         _fx_R10Ast__loc_t eloc1_6 = v_144.t1;
         fx_str_t slit_48 = FX_MAKE_STR("the argument of \'throw\' operator must be an exception");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(_fx_g21Ast_typecheck__TypExn, etyp1_7,
               &eloc1_6, &slit_48, 0), _fx_catch_62);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e1_1, &env_2, sc_2, &new_e1_7, 0), _fx_catch_62);
         FX_CALL(_fx_M3AstFM8ExpThrowN10Ast__exp_t2N10Ast__exp_tRM5loc_t(new_e1_7, &eloc_0, &result_20), _fx_catch_62);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_20, &result_0);
         FX_BREAK(_fx_catch_62);

      _fx_catch_62: ;
         if (result_20) {
            _fx_free_N10Ast__exp_t(&result_20);
         }
         if (new_e1_7) {
            _fx_free_N10Ast__exp_t(&new_e1_7);
         }
         if (etyp1_7) {
            _fx_free_N10Ast__typ_t(&etyp1_7);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_144);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 9) {
         _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_10 = &e_2->u.ExpUnary;
         if (vcase_10->t0.tag == 6) {
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_145 = {0};
            _fx_N10Ast__typ_t etyp1_8 = 0;
            _fx_N10Ast__typ_t v_146 = 0;
            _fx_N10Ast__exp_t new_e1_8 = 0;
            _fx_N10Ast__exp_t result_21 = 0;
            _fx_N10Ast__exp_t e1_2 = vcase_10->t1;
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_2, &v_145, 0), _fx_catch_63);
            FX_COPY_PTR(v_145.t0, &etyp1_8);
            FX_CALL(_fx_M3AstFM6TypRefN10Ast__typ_t1N10Ast__typ_t(etyp1_8, &v_146), _fx_catch_63);
            fx_str_t slit_49 = FX_MAKE_STR("the types of ref() operation argument and result are inconsistent");
            FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_146, &eloc_0, &slit_49, 0),
               _fx_catch_63);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  e1_2, &env_2, sc_2, &new_e1_8, 0), _fx_catch_63);
            FX_CALL(
               _fx_M3AstFM8ExpUnaryN10Ast__exp_t3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                  &_fx_g22Ast_typecheck__OpMkRef, new_e1_8, &ctx_0, &result_21), _fx_catch_63);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_21, &result_0);
            FX_BREAK(_fx_catch_63);

         _fx_catch_63: ;
            if (result_21) {
               _fx_free_N10Ast__exp_t(&result_21);
            }
            if (new_e1_8) {
               _fx_free_N10Ast__exp_t(&new_e1_8);
            }
            if (v_146) {
               _fx_free_N10Ast__typ_t(&v_146);
            }
            if (etyp1_8) {
               _fx_free_N10Ast__typ_t(&etyp1_8);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_145);
            goto _fx_endmatch_41;
         }
      }
      if (tag_0 == 9) {
         _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_11 = &e_2->u.ExpUnary;
         if (vcase_11->t0.tag == 7) {
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_147 = {0};
            _fx_N10Ast__typ_t etyp1_9 = 0;
            _fx_N10Ast__typ_t v_148 = 0;
            _fx_N10Ast__exp_t new_e1_9 = 0;
            _fx_N10Ast__exp_t result_22 = 0;
            _fx_N10Ast__exp_t e1_3 = vcase_11->t1;
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_3, &v_147, 0), _fx_catch_64);
            FX_COPY_PTR(v_147.t0, &etyp1_9);
            FX_CALL(_fx_M3AstFM6TypRefN10Ast__typ_t1N10Ast__typ_t(etyp_0, &v_148), _fx_catch_64);
            fx_str_t slit_50 = FX_MAKE_STR("the types of unary \'*\' operation argument and result are inconsistent");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(v_148, etyp1_9, &eloc_0, &slit_50, 0),
               _fx_catch_64);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  e1_3, &env_2, sc_2, &new_e1_9, 0), _fx_catch_64);
            FX_CALL(
               _fx_M3AstFM8ExpUnaryN10Ast__exp_t3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                  &_fx_g22Ast_typecheck__OpDeref, new_e1_9, &ctx_0, &result_22), _fx_catch_64);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_22, &result_0);
            FX_BREAK(_fx_catch_64);

         _fx_catch_64: ;
            if (result_22) {
               _fx_free_N10Ast__exp_t(&result_22);
            }
            if (new_e1_9) {
               _fx_free_N10Ast__exp_t(&new_e1_9);
            }
            if (v_148) {
               _fx_free_N10Ast__typ_t(&v_148);
            }
            if (etyp1_9) {
               _fx_free_N10Ast__typ_t(&etyp1_9);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_147);
            goto _fx_endmatch_41;
         }
      }
      if (tag_0 == 9) {
         _fx_N10Ast__exp_t new_e1_10 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_149 = {0};
         _fx_N10Ast__typ_t etyp1_10 = 0;
         _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_12 = &e_2->u.ExpUnary;
         _fx_N12Ast__unary_t* uop_0 = &vcase_12->t0;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               vcase_12->t1, &env_2, sc_2, &new_e1_10, 0), _fx_catch_74);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_e1_10, &v_149, 0), _fx_catch_74);
         FX_COPY_PTR(v_149.t0, &etyp1_10);
         _fx_R10Ast__loc_t eloc1_7 = v_149.t1;
         int tag_7 = uop_0->tag;
         bool res_22;
         if (tag_7 == 2) {
            res_22 = true;
         }
         else if (tag_7 == 1) {
            res_22 = true;
         }
         else if (tag_7 == 3) {
            res_22 = true;
         }
         else {
            res_22 = false;
         }
         FX_CHECK_EXN(_fx_catch_74);
         if (res_22) {
            _fx_Nt6option1N10Ast__typ_t t_opt_0 = 0;
            bool allow_fp_1;
            if (uop_0->tag == 2) {
               allow_fp_1 = true;
            }
            else {
               allow_fp_1 = uop_0->tag == 1;
            }
            FX_CALL(
               _fx_M13Ast_typecheckFM12coerce_typesNt6option1N10Ast__typ_t6N10Ast__typ_tN10Ast__typ_tBBBR10Ast__loc_t(etyp1_10,
                  etyp1_10, false, allow_fp_1, false, &eloc_0, &t_opt_0, 0), _fx_catch_67);
            int tag_8 = (t_opt_0 != 0) + 1;
            if (tag_8 == 2) {
               _fx_N10Ast__exp_t result_23 = 0;
               fx_str_t slit_51 = FX_MAKE_STR("improper type of the unary \'-\' operator result");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, t_opt_0->u.Some, &eloc_0,
                     &slit_51, 0), _fx_catch_65);
               FX_CALL(
                  _fx_M3AstFM8ExpUnaryN10Ast__exp_t3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(uop_0, new_e1_10,
                     &ctx_0, &result_23), _fx_catch_65);
               _fx_free_N10Ast__exp_t(&result_0);
               FX_COPY_PTR(result_23, &result_0);
               FX_BREAK(_fx_catch_65);

            _fx_catch_65: ;
               if (result_23) {
                  _fx_free_N10Ast__exp_t(&result_23);
               }
            }
            else if (tag_8 == 1) {
               _fx_LN10Ast__exp_t v_150 = 0;
               _fx_N10Ast__exp_t result_24 = 0;
               _fx_R9Ast__id_t f_id_3;
               FX_CALL(_fx_M3AstFM15get_unary_fnameRM4id_t2N12Ast__unary_tRM5loc_t(uop_0, &eloc_0, &f_id_3, 0), _fx_catch_66);
               FX_CALL(_fx_cons_LN10Ast__exp_t(new_e1_10, 0, true, &v_150), _fx_catch_66);
               FX_CALL(
                  _fx_M13Ast_typecheckFM19check_and_make_callN10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
                     &f_id_3, v_150, &ctx_0, &eloc_0, &env_2, etyp_0, sc_2, &result_24, 0), _fx_catch_66);
               _fx_free_N10Ast__exp_t(&result_0);
               FX_COPY_PTR(result_24, &result_0);
               FX_BREAK(_fx_catch_66);

            _fx_catch_66: ;
               if (result_24) {
                  _fx_free_N10Ast__exp_t(&result_24);
               }
               if (v_150) {
                  _fx_free_LN10Ast__exp_t(&v_150);
               }
            }
            else {
               FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_67);
            }
            FX_CHECK_EXN(_fx_catch_67);

         _fx_catch_67: ;
            if (t_opt_0) {
               _fx_free_Nt6option1N10Ast__typ_t(&t_opt_0);
            }
            goto _fx_endmatch_14;
         }
         if (tag_7 == 4) {
            _fx_N10Ast__exp_t result_25 = 0;
            fx_exn_t exn_1 = {0};
            _fx_N10Ast__typ_t v_151 = 0;
            FX_CALL(_fx_M13Ast_typecheckFM19check_unary_bitwiseN10Ast__typ_t1N10Ast__typ_t(etyp1_10, &v_151, 0), _fx_catch_68);
            fx_str_t slit_52 = FX_MAKE_STR("invalid type of bitwise-not result");
            FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_151, &eloc_0, &slit_52, 0),
               _fx_catch_68);
            FX_CALL(
               _fx_M3AstFM8ExpUnaryN10Ast__exp_t3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(uop_0, new_e1_10, &ctx_0,
                  &result_25), _fx_catch_68);

         _fx_catch_68: ;
            if (v_151) {
               _fx_free_N10Ast__typ_t(&v_151);
            }
            if (fx_status < 0) {
               fx_exn_get_and_reset(fx_status, &exn_1);
               fx_status = 0;
               if (result_25) {
                  _fx_free_N10Ast__exp_t(&result_25);
               }
               if (exn_1.tag == FX_EXN_BadArgError) {
                  _fx_LN10Ast__exp_t v_152 = 0;
                  _fx_R9Ast__id_t f_id_4;
                  FX_CALL(_fx_M3AstFM15get_unary_fnameRM4id_t2N12Ast__unary_tRM5loc_t(uop_0, &eloc_0, &f_id_4, 0),
                     _fx_catch_69);
                  FX_CALL(_fx_cons_LN10Ast__exp_t(new_e1_10, 0, true, &v_152), _fx_catch_69);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM19check_and_make_callN10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
                        &f_id_4, v_152, &ctx_0, &eloc_0, &env_2, etyp_0, sc_2, &result_25, 0), _fx_catch_69);

               _fx_catch_69: ;
                  if (v_152) {
                     _fx_free_LN10Ast__exp_t(&v_152);
                  }
               }
               else {
                  FX_RETHROW(&exn_1, _fx_catch_70);
               }
               FX_CHECK_EXN(_fx_catch_70);
            }
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_25, &result_0);
            FX_BREAK(_fx_catch_70);

         _fx_catch_70: ;
            fx_free_exn(&exn_1);
            if (result_25) {
               _fx_free_N10Ast__exp_t(&result_25);
            }
            goto _fx_endmatch_14;
         }
         if (tag_7 == 5) {
            _fx_N10Ast__exp_t result_26 = 0;
            fx_str_t slit_53 = FX_MAKE_STR("the argument of ! operator must be a boolean");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp1_10, _fx_g22Ast_typecheck__TypBool,
                  &eloc1_7, &slit_53, 0), _fx_catch_71);
            fx_str_t slit_54 = FX_MAKE_STR("the result of ! operator must be a boolean");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, _fx_g22Ast_typecheck__TypBool,
                  &eloc_0, &slit_54, 0), _fx_catch_71);
            FX_CALL(
               _fx_M3AstFM8ExpUnaryN10Ast__exp_t3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(uop_0, new_e1_10, &ctx_0,
                  &result_26), _fx_catch_71);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_26, &result_0);
            FX_BREAK(_fx_catch_71);

         _fx_catch_71: ;
            if (result_26) {
               _fx_free_N10Ast__exp_t(&result_26);
            }
            goto _fx_endmatch_14;
         }
         if (tag_7 == 9) {
            _fx_LN10Ast__exp_t v_153 = 0;
            _fx_N10Ast__exp_t result_27 = 0;
            _fx_R9Ast__id_t f_id_5;
            FX_CALL(_fx_M3AstFM15get_unary_fnameRM4id_t2N12Ast__unary_tRM5loc_t(uop_0, &eloc_0, &f_id_5, 0), _fx_catch_72);
            FX_CALL(_fx_cons_LN10Ast__exp_t(new_e1_10, 0, true, &v_153), _fx_catch_72);
            FX_CALL(
               _fx_M13Ast_typecheckFM19check_and_make_callN10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
                  &f_id_5, v_153, &ctx_0, &eloc_0, &env_2, etyp_0, sc_2, &result_27, 0), _fx_catch_72);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_27, &result_0);
            FX_BREAK(_fx_catch_72);

         _fx_catch_72: ;
            if (result_27) {
               _fx_free_N10Ast__exp_t(&result_27);
            }
            if (v_153) {
               _fx_free_LN10Ast__exp_t(&v_153);
            }
            goto _fx_endmatch_14;
         }
         fx_str_t v_154 = {0};
         fx_str_t v_155 = {0};
         fx_exn_t v_156 = {0};
         FX_CALL(_fx_M3AstFM6stringS1N12Ast__unary_t(uop_0, &v_154, 0), _fx_catch_73);
         fx_str_t slit_55 = FX_MAKE_STR("unsupported unary operation \'");
         fx_str_t slit_56 = FX_MAKE_STR("\'");
         {
            const fx_str_t strs_10[] = { slit_55, v_154, slit_56 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_10, 3, &v_155), _fx_catch_73);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_155, &v_156, 0), _fx_catch_73);
         FX_THROW(&v_156, false, _fx_catch_73);

      _fx_catch_73: ;
         fx_free_exn(&v_156);
         FX_FREE_STR(&v_155);
         FX_FREE_STR(&v_154);

      _fx_endmatch_14: ;
         FX_CHECK_EXN(_fx_catch_74);

      _fx_catch_74: ;
         if (etyp1_10) {
            _fx_free_N10Ast__typ_t(&etyp1_10);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_149);
         if (new_e1_10) {
            _fx_free_N10Ast__exp_t(&new_e1_10);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 10) {
         _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_13 = &e_2->u.ExpIntrin;
         _fx_N13Ast__intrin_t* v_157 = &vcase_13->t0;
         if (v_157->tag == 16) {
            _fx_LN10Ast__typ_t argtyps_0 = 0;
            _fx_LN10Ast__exp_t args_0 = 0;
            fx_str_t fstr_0 = {0};
            _fx_Ta2N10Ast__typ_t v_158 = {0};
            _fx_N10Ast__typ_t t_3 = 0;
            _fx_N10Ast__typ_t argt_0 = 0;
            fx_str_t v_159 = {0};
            fx_str_t v_160 = {0};
            _fx_LN10Ast__exp_t args_1 = 0;
            _fx_LN10Ast__exp_t args_2 = 0;
            _fx_N10Ast__typ_t v_161 = 0;
            _fx_N10Ast__exp_t result_28 = 0;
            _fx_R9Ast__id_t* f_1 = &v_157->u.IntrinMath;
            _fx_LN10Ast__exp_t args_3 = vcase_13->t1;
            _fx_LN10Ast__typ_t lstend_0 = 0;
            FX_COPY_PTR(args_3, &args_0);
            _fx_LN10Ast__exp_t lst_1 = args_0;
            for (; lst_1; lst_1 = lst_1->tl) {
               _fx_N10Ast__typ_t res_23 = 0;
               _fx_N10Ast__exp_t a_0 = lst_1->hd;
               FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(a_0, &res_23, 0), _fx_catch_75);
               _fx_LN10Ast__typ_t node_0 = 0;
               FX_CALL(_fx_cons_LN10Ast__typ_t(res_23, 0, false, &node_0), _fx_catch_75);
               FX_LIST_APPEND(argtyps_0, lstend_0, node_0);

            _fx_catch_75: ;
               if (res_23) {
                  _fx_free_N10Ast__typ_t(&res_23);
               }
               FX_CHECK_EXN(_fx_catch_85);
            }
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(f_1, &fstr_0, 0), _fx_catch_85);
            fx_str_t slit_57 = FX_MAKE_STR("atan2");
            if (fx_streq(&fstr_0, &slit_57)) {
               if (argtyps_0 != 0) {
                  _fx_LN10Ast__typ_t v_162 = argtyps_0->tl;
                  if (v_162 != 0) {
                     if (v_162->tl == 0) {
                        if (args_3 != 0) {
                           _fx_LN10Ast__exp_t v_163 = args_3->tl;
                           if (v_163 != 0) {
                              if (v_163->tl == 0) {
                                 _fx_N10Ast__typ_t xt_0 = v_162->hd;
                                 fx_str_t slit_58 = FX_MAKE_STR("arguments of atan2() must have the same type");
                                 FX_CALL(
                                    _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(xt_0, argtyps_0->hd,
                                       &eloc_0, &slit_58, 0), _fx_catch_76);
                                 _fx_make_Ta2N10Ast__typ_t(xt_0, xt_0, &v_158);

                              _fx_catch_76: ;
                                 goto _fx_endmatch_15;
                              }
                           }
                        }
                     }
                  }
               }
            }
            fx_str_t slit_59 = FX_MAKE_STR("pow");
            if (fx_streq(&fstr_0, &slit_59)) {
               if (argtyps_0 != 0) {
                  _fx_LN10Ast__typ_t v_164 = argtyps_0->tl;
                  if (v_164 != 0) {
                     if (v_164->tl == 0) {
                        if (args_3 != 0) {
                           _fx_LN10Ast__exp_t v_165 = args_3->tl;
                           if (v_165 != 0) {
                              if (v_165->tl == 0) {
                                 _fx_N10Ast__typ_t xt_1 = argtyps_0->hd;
                                 fx_str_t slit_60 = FX_MAKE_STR("arguments of pow() must have the same type");
                                 FX_CALL(
                                    _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(xt_1, v_164->hd,
                                       &eloc_0, &slit_60, 0), _fx_catch_77);
                                 _fx_make_Ta2N10Ast__typ_t(xt_1, xt_1, &v_158);

                              _fx_catch_77: ;
                                 goto _fx_endmatch_15;
                              }
                           }
                        }
                     }
                  }
               }
            }
            fx_str_t slit_61 = FX_MAKE_STR("min");
            if (fx_streq(&fstr_0, &slit_61)) {
               if (argtyps_0 != 0) {
                  _fx_LN10Ast__typ_t v_166 = argtyps_0->tl;
                  if (v_166 != 0) {
                     if (v_166->tl == 0) {
                        if (args_3 != 0) {
                           _fx_LN10Ast__exp_t v_167 = args_3->tl;
                           if (v_167 != 0) {
                              if (v_167->tl == 0) {
                                 _fx_N10Ast__typ_t xt_2 = argtyps_0->hd;
                                 fx_str_t slit_62 = FX_MAKE_STR("arguments of pow() must have the same type");
                                 FX_CALL(
                                    _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(xt_2, v_166->hd,
                                       &eloc_0, &slit_62, 0), _fx_catch_78);
                                 _fx_make_Ta2N10Ast__typ_t(xt_2, xt_2, &v_158);

                              _fx_catch_78: ;
                                 goto _fx_endmatch_15;
                              }
                           }
                        }
                     }
                  }
               }
            }
            fx_str_t slit_63 = FX_MAKE_STR("max");
            if (fx_streq(&fstr_0, &slit_63)) {
               if (argtyps_0 != 0) {
                  _fx_LN10Ast__typ_t v_168 = argtyps_0->tl;
                  if (v_168 != 0) {
                     if (v_168->tl == 0) {
                        if (args_3 != 0) {
                           _fx_LN10Ast__exp_t v_169 = args_3->tl;
                           if (v_169 != 0) {
                              if (v_169->tl == 0) {
                                 _fx_N10Ast__typ_t xt_3 = argtyps_0->hd;
                                 fx_str_t slit_64 = FX_MAKE_STR("arguments of pow() must have the same type");
                                 FX_CALL(
                                    _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(xt_3, v_168->hd,
                                       &eloc_0, &slit_64, 0), _fx_catch_79);
                                 _fx_make_Ta2N10Ast__typ_t(xt_3, xt_3, &v_158);

                              _fx_catch_79: ;
                                 goto _fx_endmatch_15;
                              }
                           }
                        }
                     }
                  }
               }
            }
            fx_str_t slit_65 = FX_MAKE_STR("floor");
            if (fx_streq(&fstr_0, &slit_65)) {
               if (argtyps_0 != 0) {
                  if (argtyps_0->tl == 0) {
                     if (args_3 != 0) {
                        if (args_3->tl == 0) {
                           _fx_make_Ta2N10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, argtyps_0->hd, &v_158); goto _fx_endmatch_15;
                        }
                     }
                  }
               }
            }
            fx_str_t slit_66 = FX_MAKE_STR("ceil");
            if (fx_streq(&fstr_0, &slit_66)) {
               if (argtyps_0 != 0) {
                  if (argtyps_0->tl == 0) {
                     if (args_3 != 0) {
                        if (args_3->tl == 0) {
                           _fx_make_Ta2N10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, argtyps_0->hd, &v_158); goto _fx_endmatch_15;
                        }
                     }
                  }
               }
            }
            fx_str_t slit_67 = FX_MAKE_STR("round");
            if (fx_streq(&fstr_0, &slit_67)) {
               if (argtyps_0 != 0) {
                  if (argtyps_0->tl == 0) {
                     if (args_3 != 0) {
                        if (args_3->tl == 0) {
                           _fx_make_Ta2N10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, argtyps_0->hd, &v_158); goto _fx_endmatch_15;
                        }
                     }
                  }
               }
            }
            if (argtyps_0 != 0) {
               if (argtyps_0->tl == 0) {
                  if (args_3 != 0) {
                     if (args_3->tl == 0) {
                        _fx_N10Ast__typ_t xt_4 = argtyps_0->hd;
                        _fx_make_Ta2N10Ast__typ_t(xt_4, xt_4, &v_158);
                        goto _fx_endmatch_15;
                     }
                  }
               }
            }
            fx_str_t v_170 = {0};
            fx_str_t v_171 = {0};
            fx_str_t v_172 = {0};
            fx_exn_t v_173 = {0};
            bool v_174;
            fx_str_t slit_68 = FX_MAKE_STR("atan2");
            bool t_4;
            if (_fx_F6__eq__B2SS(&fstr_0, &slit_68, 0)) {
               t_4 = true;
            }
            else {
               fx_str_t slit_69 = FX_MAKE_STR("pow"); t_4 = _fx_F6__eq__B2SS(&fstr_0, &slit_69, 0);
            }
            bool t_5;
            if (t_4) {
               t_5 = true;
            }
            else {
               fx_str_t slit_70 = FX_MAKE_STR("min"); t_5 = _fx_F6__eq__B2SS(&fstr_0, &slit_70, 0);
            }
            if (t_5) {
               v_174 = true;
            }
            else {
               fx_str_t slit_71 = FX_MAKE_STR("max"); v_174 = _fx_F6__eq__B2SS(&fstr_0, &slit_71, 0);
            }
            int_ nargs_expected_0;
            if (v_174) {
               nargs_expected_0 = 2;
            }
            else {
               nargs_expected_0 = 1;
            }
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&fstr_0, &v_170, 0), _fx_catch_80);
            FX_CALL(_fx_F6stringS1i(nargs_expected_0, &v_171, 0), _fx_catch_80);
            fx_str_t slit_72 = FX_MAKE_STR("incorrect number of arguments in __intrin_");
            fx_str_t slit_73 = FX_MAKE_STR("__, ");
            fx_str_t slit_74 = FX_MAKE_STR(" expected");
            {
               const fx_str_t strs_11[] = { slit_72, v_170, slit_73, v_171, slit_74 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_11, 5, &v_172), _fx_catch_80);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_172, &v_173, 0), _fx_catch_80);
            FX_THROW(&v_173, false, _fx_catch_80);

         _fx_catch_80: ;
            fx_free_exn(&v_173);
            FX_FREE_STR(&v_172);
            FX_FREE_STR(&v_171);
            FX_FREE_STR(&v_170);

         _fx_endmatch_15: ;
            FX_CHECK_EXN(_fx_catch_85);
            FX_COPY_PTR(v_158.t0, &t_3);
            FX_COPY_PTR(v_158.t1, &argt_0);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&fstr_0, &v_159, 0), _fx_catch_85);
            fx_str_t slit_75 = FX_MAKE_STR("the input and output of ");
            fx_str_t slit_76 = FX_MAKE_STR(" should have the same types");
            {
               const fx_str_t strs_12[] = { slit_75, v_159, slit_76 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_12, 3, &v_160), _fx_catch_85);
            }
            FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, t_3, &eloc_0, &v_160, 0),
               _fx_catch_85);
            _fx_LN10Ast__exp_t lstend_1 = 0;
            FX_COPY_PTR(args_3, &args_2);
            _fx_LN10Ast__exp_t lst_2 = args_2;
            for (; lst_2; lst_2 = lst_2->tl) {
               _fx_N10Ast__exp_t res_24 = 0;
               _fx_N10Ast__exp_t a_1 = lst_2->hd;
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     a_1, &env_2, sc_2, &res_24, 0), _fx_catch_81);
               _fx_LN10Ast__exp_t node_1 = 0;
               FX_CALL(_fx_cons_LN10Ast__exp_t(res_24, 0, false, &node_1), _fx_catch_81);
               FX_LIST_APPEND(args_1, lstend_1, node_1);

            _fx_catch_81: ;
               if (res_24) {
                  _fx_free_N10Ast__exp_t(&res_24);
               }
               FX_CHECK_EXN(_fx_catch_85);
            }
            FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t_3, &v_161, 0), _fx_catch_85);
            if (FX_REC_VARIANT_TAG(v_161) == 9) {
               goto _fx_endmatch_18;
            }
            bool res_25;
            fx_str_t slit_77 = FX_MAKE_STR("floor");
            if (fx_streq(&fstr_0, &slit_77)) {
               res_25 = true; goto _fx_endmatch_16;
            }
            fx_str_t slit_78 = FX_MAKE_STR("ceil");
            if (fx_streq(&fstr_0, &slit_78)) {
               res_25 = true; goto _fx_endmatch_16;
            }
            fx_str_t slit_79 = FX_MAKE_STR("round");
            if (fx_streq(&fstr_0, &slit_79)) {
               res_25 = true; goto _fx_endmatch_16;
            }
            res_25 = false;

         _fx_endmatch_16: ;
            FX_CHECK_EXN(_fx_catch_85);
            if (res_25) {
               if (FX_REC_VARIANT_TAG(v_161) == 5) {
                  _fx_N10Ast__typ_t v_175 = 0;
                  FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(argt_0, &v_175, 0), _fx_catch_83);
                  if (FX_REC_VARIANT_TAG(v_175) != 9) {
                     fx_exn_t v_176 = {0};
                     fx_str_t slit_80 = FX_MAKE_STR("floor/ceil/round intrinsics must have a single floating-point argument");
                     FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_80, &v_176, 0), _fx_catch_82);
                     FX_THROW(&v_176, false, _fx_catch_82);

                  _fx_catch_82: ;
                     fx_free_exn(&v_176);
                  }
                  FX_CHECK_EXN(_fx_catch_83);

               _fx_catch_83: ;
                  if (v_175) {
                     _fx_free_N10Ast__typ_t(&v_175);
                  }
                  goto _fx_endmatch_18;
               }
            }
            bool res_26;
            fx_str_t slit_81 = FX_MAKE_STR("min");
            if (fx_streq(&fstr_0, &slit_81)) {
               res_26 = true; goto _fx_endmatch_17;
            }
            fx_str_t slit_82 = FX_MAKE_STR("max");
            if (fx_streq(&fstr_0, &slit_82)) {
               res_26 = true; goto _fx_endmatch_17;
            }
            res_26 = false;

         _fx_endmatch_17: ;
            FX_CHECK_EXN(_fx_catch_85);
            if (res_26) {
               if (FX_REC_VARIANT_TAG(v_161) == 5) {
                  goto _fx_endmatch_18;
               }
            }
            fx_exn_t v_177 = {0};
            fx_str_t slit_83 =
               FX_MAKE_STR("the argument and the result of intrinsic math function must be \'float\' or \'double\'");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_83, &v_177, 0), _fx_catch_84);
            FX_THROW(&v_177, false, _fx_catch_84);

         _fx_catch_84: ;
            fx_free_exn(&v_177);

         _fx_endmatch_18: ;
            FX_CHECK_EXN(_fx_catch_85);
            _fx_N13Ast__intrin_t v_178;
            _fx_M3AstFM10IntrinMathN13Ast__intrin_t1RM4id_t(f_1, &v_178);
            FX_CALL(
               _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(&v_178, args_1, &ctx_0,
                  &result_28), _fx_catch_85);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_28, &result_0);
            FX_BREAK(_fx_catch_85);

         _fx_catch_85: ;
            if (result_28) {
               _fx_free_N10Ast__exp_t(&result_28);
            }
            if (v_161) {
               _fx_free_N10Ast__typ_t(&v_161);
            }
            if (args_2) {
               _fx_free_LN10Ast__exp_t(&args_2);
            }
            if (args_1) {
               _fx_free_LN10Ast__exp_t(&args_1);
            }
            FX_FREE_STR(&v_160);
            FX_FREE_STR(&v_159);
            if (argt_0) {
               _fx_free_N10Ast__typ_t(&argt_0);
            }
            if (t_3) {
               _fx_free_N10Ast__typ_t(&t_3);
            }
            _fx_free_Ta2N10Ast__typ_t(&v_158);
            FX_FREE_STR(&fstr_0);
            if (args_0) {
               _fx_free_LN10Ast__exp_t(&args_0);
            }
            if (argtyps_0) {
               _fx_free_LN10Ast__typ_t(&argtyps_0);
            }
            goto _fx_endmatch_41;
         }
      }
      if (tag_0 == 10) {
         _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_14 = &e_2->u.ExpIntrin;
         if (vcase_14->t0.tag == 13) {
            _fx_LN10Ast__exp_t v_179 = vcase_14->t1;
            if (v_179 != 0) {
               _fx_LN10Ast__exp_t v_180 = v_179->tl;
               if (v_180 != 0) {
                  _fx_LN10Ast__exp_t v_181 = v_180->tl;
                  if (v_181 != 0) {
                     _fx_LN10Ast__exp_t v_182 = v_181->tl;
                     if (v_182 != 0) {
                        _fx_LN10Ast__exp_t v_183 = v_182->tl;
                        if (v_183 != 0) {
                           _fx_LN10Ast__exp_t v_184 = v_183->tl;
                           if (v_184 != 0) {
                              _fx_LN10Ast__exp_t v_185 = v_184->tl;
                              if (v_185 != 0) {
                                 _fx_LN10Ast__exp_t v_186 = v_185->tl;
                                 if (v_186 != 0) {
                                    _fx_LN10Ast__exp_t v_187 = v_186->tl;
                                    if (v_187 != 0) {
                                       _fx_LN10Ast__exp_t v_188 = v_187->tl;
                                       if (v_188 != 0) {
                                          _fx_LN10Ast__exp_t v_189 = v_188->tl;
                                          if (v_189 != 0) {
                                             _fx_LN10Ast__exp_t v_190 = v_189->tl;
                                             if (v_190 != 0) {
                                                _fx_LN10Ast__exp_t v_191 = v_190->tl;
                                                if (v_191 != 0) {
                                                   _fx_LN10Ast__exp_t v_192 = v_191->tl;
                                                   if (v_192 != 0) {
                                                      _fx_LN10Ast__exp_t v_193 = v_192->tl;
                                                      if (v_193 != 0) {
                                                         _fx_LN10Ast__exp_t v_194 = v_193->tl;
                                                         if (v_194 != 0) {
                                                            if (v_194->tl == 0) {
                                                               _fx_N10Ast__exp_t v_195 = 0;
                                                               _fx_N10Ast__exp_t v_196 = 0;
                                                               _fx_N10Ast__exp_t v_197 = 0;
                                                               _fx_N10Ast__exp_t v_198 = 0;
                                                               _fx_N10Ast__exp_t v_199 = 0;
                                                               _fx_N10Ast__exp_t v_200 = 0;
                                                               _fx_N10Ast__exp_t v_201 = 0;
                                                               _fx_N10Ast__exp_t v_202 = 0;
                                                               _fx_N10Ast__exp_t v_203 = 0;
                                                               _fx_N10Ast__exp_t v_204 = 0;
                                                               _fx_N10Ast__exp_t v_205 = 0;
                                                               _fx_N10Ast__exp_t v_206 = 0;
                                                               _fx_N10Ast__exp_t v_207 = 0;
                                                               _fx_N10Ast__exp_t v_208 = 0;
                                                               _fx_N10Ast__exp_t v_209 = 0;
                                                               _fx_N10Ast__exp_t v_210 = 0;
                                                               _fx_N10Ast__typ_t v_211 = 0;
                                                               _fx_N10Ast__typ_t v_212 = 0;
                                                               _fx_N10Ast__typ_t v_213 = 0;
                                                               _fx_N10Ast__typ_t v_214 = 0;
                                                               _fx_N10Ast__typ_t v_215 = 0;
                                                               _fx_N10Ast__typ_t v_216 = 0;
                                                               _fx_N10Ast__typ_t v_217 = 0;
                                                               _fx_N10Ast__typ_t v_218 = 0;
                                                               _fx_N10Ast__typ_t v_219 = 0;
                                                               _fx_N10Ast__typ_t v_220 = 0;
                                                               _fx_N10Ast__typ_t v_221 = 0;
                                                               _fx_N10Ast__typ_t v_222 = 0;
                                                               _fx_N10Ast__typ_t v_223 = 0;
                                                               _fx_N10Ast__typ_t v_224 = 0;
                                                               _fx_N10Ast__typ_t m1typ_0 = 0;
                                                               _fx_N10Ast__typ_t m2typ_0 = 0;
                                                               _fx_N10Ast__typ_t elemtyp_0 = 0;
                                                               _fx_N10Ast__typ_t mtyp_0 = 0;
                                                               _fx_N10Ast__typ_t v_225 = 0;
                                                               _fx_N10Ast__typ_t v_226 = 0;
                                                               fx_exn_t v_227 = {0};
                                                               _fx_LN10Ast__exp_t v_228 = 0;
                                                               _fx_N10Ast__exp_t result_29 = 0;
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_179->hd, &env_2, sc_2, &v_195, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_180->hd, &env_2, sc_2, &v_196, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_181->hd, &env_2, sc_2, &v_197, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_182->hd, &env_2, sc_2, &v_198, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_183->hd, &env_2, sc_2, &v_199, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_184->hd, &env_2, sc_2, &v_200, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_185->hd, &env_2, sc_2, &v_201, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_186->hd, &env_2, sc_2, &v_202, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_187->hd, &env_2, sc_2, &v_203, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_188->hd, &env_2, sc_2, &v_204, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_189->hd, &env_2, sc_2, &v_205, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_190->hd, &env_2, sc_2, &v_206, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_191->hd, &env_2, sc_2, &v_207, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_192->hd, &env_2, sc_2, &v_208, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_193->hd, &env_2, sc_2, &v_209, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                                     v_194->hd, &env_2, sc_2, &v_210, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_196,
                                                                     &v_211, 0), _fx_catch_86);
                                                               fx_str_t slit_84 = FX_MAKE_STR("t1 should be boolean");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_211, _fx_g22Ast_typecheck__TypBool, &eloc_0, &slit_84,
                                                                     0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_204,
                                                                     &v_212, 0), _fx_catch_86);
                                                               fx_str_t slit_85 = FX_MAKE_STR("t1 should be boolean");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_212, _fx_g22Ast_typecheck__TypBool, &eloc_0, &slit_85,
                                                                     0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_197,
                                                                     &v_213, 0), _fx_catch_86);
                                                               fx_str_t slit_86 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_213, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_86, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_198,
                                                                     &v_214, 0), _fx_catch_86);
                                                               fx_str_t slit_87 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_214, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_87, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_199,
                                                                     &v_215, 0), _fx_catch_86);
                                                               fx_str_t slit_88 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_215, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_88, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_200,
                                                                     &v_216, 0), _fx_catch_86);
                                                               fx_str_t slit_89 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_216, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_89, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_201,
                                                                     &v_217, 0), _fx_catch_86);
                                                               fx_str_t slit_90 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_217, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_90, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_202,
                                                                     &v_218, 0), _fx_catch_86);
                                                               fx_str_t slit_91 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_218, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_91, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_205,
                                                                     &v_219, 0), _fx_catch_86);
                                                               fx_str_t slit_92 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_219, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_92, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_206,
                                                                     &v_220, 0), _fx_catch_86);
                                                               fx_str_t slit_93 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_220, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_93, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_207,
                                                                     &v_221, 0), _fx_catch_86);
                                                               fx_str_t slit_94 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_221, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_94, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_208,
                                                                     &v_222, 0), _fx_catch_86);
                                                               fx_str_t slit_95 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_222, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_95, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_209,
                                                                     &v_223, 0), _fx_catch_86);
                                                               fx_str_t slit_96 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_223, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_96, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_210,
                                                                     &v_224, 0), _fx_catch_86);
                                                               fx_str_t slit_97 =
                                                                  FX_MAKE_STR(
                                                                     "range boundaries/delta\'s should all be integers");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     v_224, _fx_g21Ast_typecheck__TypInt, &eloc_0, &slit_97, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_195,
                                                                     &m1typ_0, 0), _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(v_203,
                                                                     &m2typ_0, 0), _fx_catch_86);
                                                               fx_str_t slit_98 =
                                                                  FX_MAKE_STR("m1 and m2 should have the same type");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     m1typ_0, m2typ_0, &eloc_0, &slit_98, 0), _fx_catch_86);
                                                               FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&elemtyp_0, 0),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(2, elemtyp_0,
                                                                     &mtyp_0), _fx_catch_86);
                                                               fx_str_t slit_99 =
                                                                  FX_MAKE_STR("m1 and m2 should be 2 dimensional arrays");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     m1typ_0, mtyp_0, &eloc_0, &slit_99, 0), _fx_catch_86);
                                                               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(32, &v_225),
                                                                  _fx_catch_86);
                                                               bool v_229;
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(
                                                                     elemtyp_0, v_225, &eloc_0, true, &v_229, 0), _fx_catch_86);
                                                               bool v_230;
                                                               if (!v_229) {
                                                                  FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(64, &v_226),
                                                                     _fx_catch_86);
                                                                  bool v_231;
                                                                  FX_CALL(
                                                                     _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(
                                                                        elemtyp_0, v_226, &eloc_0, true, &v_231, 0),
                                                                     _fx_catch_86);
                                                                  v_230 = !v_231;
                                                               }
                                                               else {
                                                                  v_230 = false;
                                                               }
                                                               if (v_230) {
                                                                  fx_str_t slit_100 =
                                                                     FX_MAKE_STR(
                                                                        "multiplied matrices should contain float or double elements");
                                                                  FX_CALL(
                                                                     _fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_100,
                                                                        &v_227, 0), _fx_catch_86);
                                                                  FX_THROW(&v_227, false, _fx_catch_86);
                                                               }
                                                               fx_str_t slit_101 =
                                                                  FX_MAKE_STR(
                                                                     "the result of GEMM must be the same as the type of arguments");
                                                               FX_CALL(
                                                                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                                     etyp_0, mtyp_0, &eloc_0, &slit_101, 0), _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_210, 0, true, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_209, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_208, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_207, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_206, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_205, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_204, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_203, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_202, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_201, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_200, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_199, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_198, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_197, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_196, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(_fx_cons_LN10Ast__exp_t(v_195, v_228, false, &v_228),
                                                                  _fx_catch_86);
                                                               FX_CALL(
                                                                  _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                                     &_fx_g25Ast_typecheck__IntrinGEMM, v_228, &ctx_0,
                                                                     &result_29), _fx_catch_86);
                                                               _fx_free_N10Ast__exp_t(&result_0);
                                                               FX_COPY_PTR(result_29, &result_0);
                                                               FX_BREAK(_fx_catch_86);

                                                            _fx_catch_86: ;
                                                               if (result_29) {
                                                                  _fx_free_N10Ast__exp_t(&result_29);
                                                               }
                                                               if (v_228) {
                                                                  _fx_free_LN10Ast__exp_t(&v_228);
                                                               }
                                                               fx_free_exn(&v_227);
                                                               if (v_226) {
                                                                  _fx_free_N10Ast__typ_t(&v_226);
                                                               }
                                                               if (v_225) {
                                                                  _fx_free_N10Ast__typ_t(&v_225);
                                                               }
                                                               if (mtyp_0) {
                                                                  _fx_free_N10Ast__typ_t(&mtyp_0);
                                                               }
                                                               if (elemtyp_0) {
                                                                  _fx_free_N10Ast__typ_t(&elemtyp_0);
                                                               }
                                                               if (m2typ_0) {
                                                                  _fx_free_N10Ast__typ_t(&m2typ_0);
                                                               }
                                                               if (m1typ_0) {
                                                                  _fx_free_N10Ast__typ_t(&m1typ_0);
                                                               }
                                                               if (v_224) {
                                                                  _fx_free_N10Ast__typ_t(&v_224);
                                                               }
                                                               if (v_223) {
                                                                  _fx_free_N10Ast__typ_t(&v_223);
                                                               }
                                                               if (v_222) {
                                                                  _fx_free_N10Ast__typ_t(&v_222);
                                                               }
                                                               if (v_221) {
                                                                  _fx_free_N10Ast__typ_t(&v_221);
                                                               }
                                                               if (v_220) {
                                                                  _fx_free_N10Ast__typ_t(&v_220);
                                                               }
                                                               if (v_219) {
                                                                  _fx_free_N10Ast__typ_t(&v_219);
                                                               }
                                                               if (v_218) {
                                                                  _fx_free_N10Ast__typ_t(&v_218);
                                                               }
                                                               if (v_217) {
                                                                  _fx_free_N10Ast__typ_t(&v_217);
                                                               }
                                                               if (v_216) {
                                                                  _fx_free_N10Ast__typ_t(&v_216);
                                                               }
                                                               if (v_215) {
                                                                  _fx_free_N10Ast__typ_t(&v_215);
                                                               }
                                                               if (v_214) {
                                                                  _fx_free_N10Ast__typ_t(&v_214);
                                                               }
                                                               if (v_213) {
                                                                  _fx_free_N10Ast__typ_t(&v_213);
                                                               }
                                                               if (v_212) {
                                                                  _fx_free_N10Ast__typ_t(&v_212);
                                                               }
                                                               if (v_211) {
                                                                  _fx_free_N10Ast__typ_t(&v_211);
                                                               }
                                                               if (v_210) {
                                                                  _fx_free_N10Ast__exp_t(&v_210);
                                                               }
                                                               if (v_209) {
                                                                  _fx_free_N10Ast__exp_t(&v_209);
                                                               }
                                                               if (v_208) {
                                                                  _fx_free_N10Ast__exp_t(&v_208);
                                                               }
                                                               if (v_207) {
                                                                  _fx_free_N10Ast__exp_t(&v_207);
                                                               }
                                                               if (v_206) {
                                                                  _fx_free_N10Ast__exp_t(&v_206);
                                                               }
                                                               if (v_205) {
                                                                  _fx_free_N10Ast__exp_t(&v_205);
                                                               }
                                                               if (v_204) {
                                                                  _fx_free_N10Ast__exp_t(&v_204);
                                                               }
                                                               if (v_203) {
                                                                  _fx_free_N10Ast__exp_t(&v_203);
                                                               }
                                                               if (v_202) {
                                                                  _fx_free_N10Ast__exp_t(&v_202);
                                                               }
                                                               if (v_201) {
                                                                  _fx_free_N10Ast__exp_t(&v_201);
                                                               }
                                                               if (v_200) {
                                                                  _fx_free_N10Ast__exp_t(&v_200);
                                                               }
                                                               if (v_199) {
                                                                  _fx_free_N10Ast__exp_t(&v_199);
                                                               }
                                                               if (v_198) {
                                                                  _fx_free_N10Ast__exp_t(&v_198);
                                                               }
                                                               if (v_197) {
                                                                  _fx_free_N10Ast__exp_t(&v_197);
                                                               }
                                                               if (v_196) {
                                                                  _fx_free_N10Ast__exp_t(&v_196);
                                                               }
                                                               if (v_195) {
                                                                  _fx_free_N10Ast__exp_t(&v_195);
                                                               }
                                                               goto _fx_endmatch_41;
                                                            }
                                                         }
                                                      }
                                                   }
                                                }
                                             }
                                          }
                                       }
                                    }
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }
      if (tag_0 == 10) {
         _fx_T3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_15 = &e_2->u.ExpIntrin;
         _fx_LN10Ast__exp_t args_4 = vcase_15->t1;
         _fx_N13Ast__intrin_t* iop_0 = &vcase_15->t0;
         if (iop_0->tag == 9) {
            _fx_T2N10Ast__exp_ti v_232 = {0};
            _fx_N10Ast__exp_t a_2 = 0;
            _fx_N10Ast__exp_t a_3 = 0;
            _fx_N10Ast__typ_t t_6 = 0;
            _fx_N10Ast__typ_t v_233 = 0;
            _fx_LN10Ast__exp_t v_234 = 0;
            _fx_LN10Ast__exp_t v_235 = 0;
            _fx_N10Ast__exp_t result_30 = 0;
            if (args_4 != 0) {
               if (args_4->tl == 0) {
                  _fx_make_T2N10Ast__exp_ti(args_4->hd, 0, &v_232); goto _fx_endmatch_19;
               }
            }
            if (args_4 != 0) {
               _fx_LN10Ast__exp_t v_236 = args_4->tl;
               if (v_236 != 0) {
                  if (v_236->tl == 0) {
                     _fx_N10Ast__exp_t v_237 = v_236->hd;
                     if (FX_REC_VARIANT_TAG(v_237) == 6) {
                        _fx_N10Ast__lit_t* v_238 = &v_237->u.ExpLit.t0;
                        if (v_238->tag == 1) {
                           int_ res_27;
                           FX_CALL(_fx_M13Ast_typecheckFM3inti1l(v_238->u.LitInt, &res_27, 0), _fx_catch_87);
                           _fx_make_T2N10Ast__exp_ti(args_4->hd, res_27, &v_232);

                        _fx_catch_87: ;
                           goto _fx_endmatch_19;
                        }
                     }
                  }
               }
            }
            fx_exn_t v_239 = {0};
            fx_str_t slit_102 =
               FX_MAKE_STR(
                  "there should be exactly one or two argument of __intrin_size__ intrinsic. In the latter case the second parameter must be literal integer");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_102, &v_239, 0), _fx_catch_88);
            FX_THROW(&v_239, false, _fx_catch_88);

         _fx_catch_88: ;
            fx_free_exn(&v_239);

         _fx_endmatch_19: ;
            FX_CHECK_EXN(_fx_catch_91);
            FX_COPY_PTR(v_232.t0, &a_2);
            int_ idx_0 = v_232.t1;
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  a_2, &env_2, sc_2, &a_3, 0), _fx_catch_91);
            FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(a_3, &t_6, 0), _fx_catch_91);
            fx_str_t slit_103 = FX_MAKE_STR("the result of __intrin_size__ must be integer");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, _fx_g21Ast_typecheck__TypInt,
                  &eloc_0, &slit_103, 0), _fx_catch_91);
            FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t_6, &v_233, 0), _fx_catch_91);
            if (idx_0 == 0) {
               if (FX_REC_VARIANT_TAG(v_233) == 10) {
                  goto _fx_endmatch_20;
               }
            }
            if (idx_0 == 0) {
               if (FX_REC_VARIANT_TAG(v_233) == 16) {
                  goto _fx_endmatch_20;
               }
            }
            if (FX_REC_VARIANT_TAG(v_233) == 19) {
               fx_exn_t v_240 = {0};
               bool t_7;
               if (idx_0 < 0) {
                  t_7 = true;
               }
               else {
                  t_7 = idx_0 >= v_233->u.TypArray.t0;
               }
               if (t_7) {
                  fx_str_t slit_104 = FX_MAKE_STR("the argument of __intrin_size__ is outside of array dimensionality");
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_104, &v_240, 0), _fx_catch_89);
                  FX_THROW(&v_240, false, _fx_catch_89);
               }

            _fx_catch_89: ;
               fx_free_exn(&v_240);
               goto _fx_endmatch_20;
            }
            fx_exn_t v_241 = {0};
            fx_str_t slit_105 = FX_MAKE_STR("the argument of __intrin_size__ must be a string, a vector or an array");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_105, &v_241, 0), _fx_catch_90);
            FX_THROW(&v_241, false, _fx_catch_90);

         _fx_catch_90: ;
            fx_free_exn(&v_241);

         _fx_endmatch_20: ;
            FX_CHECK_EXN(_fx_catch_91);
            if (idx_0 > 0) {
               FX_CALL(_fx_M13Ast_typecheckFM2tlLN10Ast__exp_t1LN10Ast__exp_t(args_4, &v_234, 0), _fx_catch_91);
            }
            FX_CALL(_fx_cons_LN10Ast__exp_t(a_3, v_234, true, &v_235), _fx_catch_91);
            FX_CALL(
               _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(iop_0, v_235, &ctx_0,
                  &result_30), _fx_catch_91);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_30, &result_0);
            FX_BREAK(_fx_catch_91);

         _fx_catch_91: ;
            if (result_30) {
               _fx_free_N10Ast__exp_t(&result_30);
            }
            if (v_235) {
               _fx_free_LN10Ast__exp_t(&v_235);
            }
            if (v_234) {
               _fx_free_LN10Ast__exp_t(&v_234);
            }
            if (v_233) {
               _fx_free_N10Ast__typ_t(&v_233);
            }
            if (t_6) {
               _fx_free_N10Ast__typ_t(&t_6);
            }
            if (a_3) {
               _fx_free_N10Ast__exp_t(&a_3);
            }
            if (a_2) {
               _fx_free_N10Ast__exp_t(&a_2);
            }
            _fx_free_T2N10Ast__exp_ti(&v_232);
         }
         else {
            fx_str_t v_242 = {0};
            fx_str_t v_243 = {0};
            fx_exn_t v_244 = {0};
            FX_CALL(_fx_M3AstFM6stringS1N13Ast__intrin_t(iop_0, &v_242, 0), _fx_catch_92);
            fx_str_t slit_106 = FX_MAKE_STR("the intrinsic \'");
            fx_str_t slit_107 = FX_MAKE_STR("\' is not supported by the type checker");
            {
               const fx_str_t strs_13[] = { slit_106, v_242, slit_107 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_13, 3, &v_243), _fx_catch_92);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_243, &v_244, 0), _fx_catch_92);
            FX_THROW(&v_244, false, _fx_catch_92);

         _fx_catch_92: ;
            fx_free_exn(&v_244);
            FX_FREE_STR(&v_243);
            FX_FREE_STR(&v_242);
         }
         FX_CHECK_EXN(_fx_catch_93);

      _fx_catch_93: ;
         goto _fx_endmatch_41;
      }
      if (tag_0 == 12) {
         _fx_N10Ast__typ_t eseq_typ_0 = 0;
         _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_245 = {0};
         _fx_LN10Ast__exp_t eseq_0 = 0;
         _fx_N10Ast__exp_t result_31 = 0;
         _fx_LN10Ast__exp_t eseq_1 = e_2->u.ExpSeq.t0;
         bool is_func_body_0;
         if (sc_2 != 0) {
            if (sc_2->hd.tag == 7) {
               is_func_body_0 = true; goto _fx_endmatch_21;
            }
         }
         if (sc_2 != 0) {
            if (sc_2->hd.tag == 1) {
               _fx_LN12Ast__scope_t v_246 = sc_2->tl;
               if (v_246 != 0) {
                  if (v_246->hd.tag == 7) {
                     is_func_body_0 = true; goto _fx_endmatch_21;
                  }
               }
            }
         }
         is_func_body_0 = false;

      _fx_endmatch_21: ;
         FX_CHECK_EXN(_fx_catch_95);
         if (eseq_1 == 0) {
            FX_COPY_PTR(_fx_g22Ast_typecheck__TypVoid, &eseq_typ_0);
         }
         else {
            _fx_N10Ast__exp_t last_exp_0 = 0;
            _fx_N10Ast__exp_t last_exp_1 = 0;
            FX_CALL(_fx_M13Ast_typecheckFM4lastN10Ast__exp_t1LN10Ast__exp_t(eseq_1, &last_exp_0, 0), _fx_catch_94);
            if (FX_REC_VARIANT_TAG(last_exp_0) == 4) {
               _fx_Nt6option1N10Ast__exp_t v_247 = last_exp_0->u.ExpReturn.t0;
               if ((v_247 != 0) + 1 == 2) {
                  if (is_func_body_0) {
                     FX_COPY_PTR(v_247->u.Some, &last_exp_1); goto _fx_endmatch_22;
                  }
               }
            }
            FX_COPY_PTR(last_exp_0, &last_exp_1);

         _fx_endmatch_22: ;
            FX_CHECK_EXN(_fx_catch_94);
            FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(last_exp_1, &eseq_typ_0, 0), _fx_catch_94);

         _fx_catch_94: ;
            if (last_exp_1) {
               _fx_free_N10Ast__exp_t(&last_exp_1);
            }
            if (last_exp_0) {
               _fx_free_N10Ast__exp_t(&last_exp_0);
            }
         }
         FX_CHECK_EXN(_fx_catch_95);
         fx_str_t slit_108 = FX_MAKE_STR("the expected type of block expression does not match its actual type");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, eseq_typ_0, &eloc_0, &slit_108, 0),
            _fx_catch_95);
         FX_CALL(
            _fx_M13Ast_typecheckFM10check_eseqT2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tB(
               eseq_1, &env_2, sc_2, true, &v_245, 0), _fx_catch_95);
         FX_COPY_PTR(v_245.t0, &eseq_0);
         FX_CALL(_fx_M3AstFM6ExpSeqN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(eseq_0, &ctx_0, &result_31),
            _fx_catch_95);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_31, &result_0);
         FX_BREAK(_fx_catch_95);

      _fx_catch_95: ;
         if (result_31) {
            _fx_free_N10Ast__exp_t(&result_31);
         }
         if (eseq_0) {
            _fx_free_LN10Ast__exp_t(&eseq_0);
         }
         _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_245);
         if (eseq_typ_0) {
            _fx_free_N10Ast__typ_t(&eseq_typ_0);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 11) {
         _fx_N10Ast__exp_t e_3 = 0;
         _fx_N10Ast__exp_t result_32 = 0;
         _fx_T2R9Ast__id_tN10Ast__exp_t* vcase_16 = &e_2->u.ExpSync;
         FX_CALL(
            _fx_M13Ast_typecheckFM16check_inside_forv5BBBLN12Ast__scope_tR10Ast__loc_t(false, false, true, sc_2, &eloc_0, 0),
            _fx_catch_96);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               vcase_16->t1, &env_2, sc_2, &e_3, 0), _fx_catch_96);
         FX_CALL(_fx_M3AstFM7ExpSyncN10Ast__exp_t2RM4id_tN10Ast__exp_t(&vcase_16->t0, e_3, &result_32), _fx_catch_96);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_32, &result_0);
         FX_BREAK(_fx_catch_96);

      _fx_catch_96: ;
         if (result_32) {
            _fx_free_N10Ast__exp_t(&result_32);
         }
         if (e_3) {
            _fx_free_N10Ast__exp_t(&e_3);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 13) {
         _fx_LN10Ast__typ_t tl_0 = 0;
         _fx_LN10Ast__exp_t el_0 = 0;
         _fx_N10Ast__typ_t v_248 = 0;
         _fx_LN10Ast__exp_t v_249 = 0;
         _fx_LN10Ast__exp_t el_1 = 0;
         _fx_N10Ast__exp_t result_33 = 0;
         _fx_LN10Ast__exp_t el_2 = e_2->u.ExpMkTuple.t0;
         _fx_LN10Ast__typ_t lstend_2 = 0;
         FX_COPY_PTR(el_2, &el_0);
         _fx_LN10Ast__exp_t lst_3 = el_0;
         for (; lst_3; lst_3 = lst_3->tl) {
            _fx_N10Ast__typ_t res_28 = 0;
            _fx_N10Ast__exp_t e_4 = lst_3->hd;
            FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(e_4, &res_28, 0), _fx_catch_97);
            _fx_LN10Ast__typ_t node_2 = 0;
            FX_CALL(_fx_cons_LN10Ast__typ_t(res_28, 0, false, &node_2), _fx_catch_97);
            FX_LIST_APPEND(tl_0, lstend_2, node_2);

         _fx_catch_97: ;
            if (res_28) {
               _fx_free_N10Ast__typ_t(&res_28);
            }
            FX_CHECK_EXN(_fx_catch_99);
         }
         FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(tl_0, &v_248), _fx_catch_99);
         fx_str_t slit_109 = FX_MAKE_STR("improper type of tuple elements or the number of elements");
         FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_248, &eloc_0, &slit_109, 0),
            _fx_catch_99);
         _fx_LN10Ast__exp_t lstend_3 = 0;
         FX_COPY_PTR(el_2, &el_1);
         _fx_LN10Ast__exp_t lst_4 = el_1;
         for (; lst_4; lst_4 = lst_4->tl) {
            _fx_N10Ast__exp_t res_29 = 0;
            _fx_N10Ast__exp_t e_5 = lst_4->hd;
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  e_5, &env_2, sc_2, &res_29, 0), _fx_catch_98);
            _fx_LN10Ast__exp_t node_3 = 0;
            FX_CALL(_fx_cons_LN10Ast__exp_t(res_29, 0, false, &node_3), _fx_catch_98);
            FX_LIST_APPEND(v_249, lstend_3, node_3);

         _fx_catch_98: ;
            if (res_29) {
               _fx_free_N10Ast__exp_t(&res_29);
            }
            FX_CHECK_EXN(_fx_catch_99);
         }
         FX_CALL(_fx_M3AstFM10ExpMkTupleN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_249, &ctx_0, &result_33),
            _fx_catch_99);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_33, &result_0);
         FX_BREAK(_fx_catch_99);

      _fx_catch_99: ;
         if (result_33) {
            _fx_free_N10Ast__exp_t(&result_33);
         }
         if (el_1) {
            _fx_free_LN10Ast__exp_t(&el_1);
         }
         if (v_249) {
            _fx_free_LN10Ast__exp_t(&v_249);
         }
         if (v_248) {
            _fx_free_N10Ast__typ_t(&v_248);
         }
         if (el_0) {
            _fx_free_LN10Ast__exp_t(&el_0);
         }
         if (tl_0) {
            _fx_free_LN10Ast__typ_t(&tl_0);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 18) {
         _fx_N10Ast__exp_t f_2 = 0;
         _fx_FPN10Ast__exp_t1N10Ast__exp_t dup_exp_0 = {0};
         _fx_LN10Ast__exp_t args_5 = 0;
         _fx_LN10Ast__typ_t arg_typs_0 = 0;
         _fx_N10Ast__typ_t f_expected_typ_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_250 = {0};
         _fx_N10Ast__typ_t f_real_typ_0 = 0;
         fx_str_t v_251 = {0};
         fx_str_t v_252 = {0};
         fx_str_t v_253 = {0};
         fx_str_t v_254 = {0};
         fx_str_t v_255 = {0};
         _fx_LT2N10Ast__exp_tB new_args_0 = 0;
         _fx_N10Ast__exp_t result_34 = 0;
         fx_exn_t exn_2 = {0};
         _fx_T3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_17 = &e_2->u.ExpCall;
         _fx_LN10Ast__exp_t args0_0 = vcase_17->t1;
         _fx_N10Ast__exp_t f0_0 = vcase_17->t0;
         FX_CALL(_fx_M3AstFM7dup_expN10Ast__exp_t1N10Ast__exp_t(f0_0, &f_2, 0), _fx_catch_117);
         _fx_FPN10Ast__exp_t1N10Ast__exp_t dup_exp_fp_0 = { _fx_M3AstFM7dup_expN10Ast__exp_t1N10Ast__exp_t, 0 };
         FX_COPY_FP(&dup_exp_fp_0, &dup_exp_0);
         FX_CALL(
            _fx_M13Ast_typecheckFM3mapLN10Ast__exp_t2LN10Ast__exp_tFPN10Ast__exp_t1N10Ast__exp_t(args0_0, &dup_exp_0, &args_5,
               0), _fx_catch_117);
         _fx_LN10Ast__typ_t lstend_4 = 0;
         _fx_LN10Ast__exp_t lst_5 = args_5;
         for (; lst_5; lst_5 = lst_5->tl) {
            _fx_N10Ast__typ_t res_30 = 0;
            _fx_N10Ast__exp_t a_4 = lst_5->hd;
            FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(a_4, &res_30, 0), _fx_catch_100);
            _fx_LN10Ast__typ_t node_4 = 0;
            FX_CALL(_fx_cons_LN10Ast__typ_t(res_30, 0, false, &node_4), _fx_catch_100);
            FX_LIST_APPEND(arg_typs_0, lstend_4, node_4);

         _fx_catch_100: ;
            if (res_30) {
               _fx_free_N10Ast__typ_t(&res_30);
            }
            FX_CHECK_EXN(_fx_catch_117);
         }
         FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(arg_typs_0, etyp_0, &f_expected_typ_0),
            _fx_catch_117);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(f_2, &v_250, 0), _fx_catch_117);
         FX_COPY_PTR(v_250.t0, &f_real_typ_0);
         _fx_R10Ast__loc_t floc_0 = v_250.t1;
         FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(f_real_typ_0, &v_251, 0), _fx_catch_117);
         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_251, &v_252, 0), _fx_catch_117);
         FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(f_expected_typ_0, &v_253, 0), _fx_catch_117);
         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_253, &v_254, 0), _fx_catch_117);
         fx_str_t slit_110 = FX_MAKE_STR("the real \'");
         fx_str_t slit_111 = FX_MAKE_STR("\' and expected \'");
         fx_str_t slit_112 = FX_MAKE_STR("\' function type do not match");
         {
            const fx_str_t strs_14[] = { slit_110, v_252, slit_111, v_254, slit_112 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_14, 5, &v_255), _fx_catch_117);
         }
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(f_real_typ_0, f_expected_typ_0, &floc_0,
               &v_255, 0), _fx_catch_117);
         _fx_LT2N10Ast__exp_tB lstend_5 = 0;
         _fx_LN10Ast__exp_t lst_6 = args_5;
         for (; lst_6; lst_6 = lst_6->tl) {
            _fx_R13Ast__deffun_t v_256 = {0};
            _fx_T2N10Ast__exp_tB t_8 = {0};
            _fx_N10Ast__exp_t v_257 = 0;
            _fx_N10Ast__exp_t a_5 = lst_6->hd;
            int tag_9 = FX_REC_VARIANT_TAG(a_5);
            bool need_to_check_0;
            if (tag_9 == 12) {
               _fx_LN10Ast__exp_t v_258 = a_5->u.ExpSeq.t0;
               if (v_258 != 0) {
                  _fx_LN10Ast__exp_t v_259 = v_258->tl;
                  if (v_259 != 0) {
                     if (v_259->tl == 0) {
                        _fx_N10Ast__exp_t v_260 = v_259->hd;
                        if (FX_REC_VARIANT_TAG(v_260) == 7) {
                           _fx_R9Ast__id_t* f_3 = &v_260->u.ExpIdent.t0;
                           _fx_N10Ast__exp_t exp_df_0 = v_258->hd;
                           if (FX_REC_VARIANT_TAG(exp_df_0) == 35) {
                              _fx_copy_R13Ast__deffun_t(&exp_df_0->u.DefFun->data, &v_256);
                              _fx_R9Ast__id_t v_261;
                              FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(f_3, &v_261, 0), _fx_catch_108);
                              bool res_31;
                              FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_261, &_fx_g18Ast__std__lambda__, &res_31, 0),
                                 _fx_catch_108);
                              bool t_9;
                              if (res_31) {
                                 FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(f_3, &v_256.df_name, &t_9, 0), _fx_catch_108);
                              }
                              else {
                                 t_9 = false;
                              }
                              if (t_9) {
                                 _fx_N10Ast__exp_t v_262 = 0;
                                 _fx_rR13Ast__deffun_t df_0 = 0;
                                 _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t res_32 = {0};
                                 _fx_LR9Ast__id_t v_263 = 0;
                                 FX_CALL(_fx_M3AstFM7dup_expN10Ast__exp_t1N10Ast__exp_t(exp_df_0, &v_262, 0), _fx_catch_102);
                                 if (FX_REC_VARIANT_TAG(v_262) == 35) {
                                    FX_COPY_PTR(v_262->u.DefFun, &df_0);
                                 }
                                 else {
                                    fx_exn_t v_264 = {0};
                                    fx_str_t slit_113 = FX_MAKE_STR("after duplication function is not a function anymore!");
                                    FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&v_256.df_loc, &slit_113, &v_264, 0),
                                       _fx_catch_101);
                                    FX_THROW(&v_264, false, _fx_catch_101);

                                 _fx_catch_101: ;
                                    fx_free_exn(&v_264);
                                 }
                                 FX_CHECK_EXN(_fx_catch_102);
                                 FX_CALL(
                                    _fx_M13Ast_typecheckFM10reg_deffunRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3rR13Ast__deffun_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                       df_0, &env_2, sc_2, &res_32, 0), _fx_catch_102);
                                 FX_COPY_PTR(df_0->data.df_templ_args, &v_263);
                                 need_to_check_0 = v_263 == 0;

                              _fx_catch_102: ;
                                 FX_FREE_LIST_SIMPLE(&v_263);
                                 _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&res_32);
                                 if (df_0) {
                                    _fx_free_rR13Ast__deffun_t(&df_0);
                                 }
                                 if (v_262) {
                                    _fx_free_N10Ast__exp_t(&v_262);
                                 }
                                 goto _fx_endmatch_25;
                              }
                           }
                        }
                     }
                  }
               }
            }
            bool res_33;
            if (tag_9 == 7) {
               res_33 = true; goto _fx_endmatch_23;
            }
            if (tag_9 == 21) {
               if (FX_REC_VARIANT_TAG(a_5->u.ExpMem.t1) == 7) {
                  res_33 = true; goto _fx_endmatch_23;
               }
            }
            res_33 = false;

         _fx_endmatch_23: ;
            FX_CHECK_EXN(_fx_catch_108);
            if (res_33) {
               _fx_N10Ast__exp_t v_265 = 0;
               _fx_N10Ast__exp_t v_266 = 0;
               _fx_N10Ast__typ_t v_267 = 0;
               FX_CALL(_fx_M3AstFM7dup_expN10Ast__exp_t1N10Ast__exp_t(a_5, &v_265, 0), _fx_catch_107);
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     v_265, &env_2, sc_2, &v_266, 0), _fx_catch_107);
               if (FX_REC_VARIANT_TAG(v_266) == 7) {
                  _fx_T2R9Ast__id_tT2N10Ast__typ_tR10Ast__loc_t* vcase_18 = &v_266->u.ExpIdent;
                  _fx_R9Ast__id_t* f_4 = &vcase_18->t0;
                  FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(vcase_18->t1.t0, &v_267, 0), _fx_catch_107);
                  bool res_34;
                  if (FX_REC_VARIANT_TAG(v_267) == 14) {
                     res_34 = true;
                  }
                  else {
                     res_34 = false;
                  }
                  FX_CHECK_EXN(_fx_catch_107);
                  if (res_34) {
                     _fx_N14Ast__id_info_t v_268 = {0};
                     FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(f_4, &eloc_0, &v_268, 0), _fx_catch_106);
                     if (v_268.tag == 3) {
                        _fx_R13Ast__deffun_t v_269 = {0};
                        _fx_LN16Ast__env_entry_t all_entries_0 = 0;
                        _fx_copy_R13Ast__deffun_t(&v_268.u.IdFun->data, &v_269);
                        _fx_R9Ast__id_t v_270;
                        FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(f_4, &v_270, 0), _fx_catch_105);
                        FX_CALL(
                           _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
                              &v_270, &v_269.df_env, &all_entries_0, 0), _fx_catch_105);
                        int_ __fold_result___1 = 0;
                        _fx_LN16Ast__env_entry_t lst_7 = all_entries_0;
                        for (; lst_7; lst_7 = lst_7->tl) {
                           _fx_N16Ast__env_entry_t entry_0 = lst_7->hd;
                           int_ new_matches_0;
                           if (FX_REC_VARIANT_TAG(entry_0) == 1) {
                              _fx_N14Ast__id_info_t v_271 = {0};
                              FX_CALL(
                                 _fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&entry_0->u.EnvId, &eloc_0, &v_271, 0),
                                 _fx_catch_103);
                              if (v_271.tag == 3) {
                                 _fx_R13Ast__deffun_t v_272 = {0};
                                 _fx_copy_R13Ast__deffun_t(&v_271.u.IdFun->data, &v_272);
                                 if (v_272.df_templ_args != 0) {
                                    new_matches_0 = 100;
                                 }
                                 else {
                                    new_matches_0 = 1;
                                 }
                                 _fx_free_R13Ast__deffun_t(&v_272);
                              }
                              else {
                                 new_matches_0 = 0;
                              }
                              FX_CHECK_EXN(_fx_catch_103);

                           _fx_catch_103: ;
                              _fx_free_N14Ast__id_info_t(&v_271);
                           }
                           else {
                              new_matches_0 = 0;
                           }
                           FX_CHECK_EXN(_fx_catch_104);
                           __fold_result___1 = __fold_result___1 + new_matches_0;

                        _fx_catch_104: ;
                           FX_CHECK_EXN(_fx_catch_105);
                        }
                        int_ possible_matches_0 = __fold_result___1;
                        need_to_check_0 = possible_matches_0 <= 1;

                     _fx_catch_105: ;
                        if (all_entries_0) {
                           _fx_free_LN16Ast__env_entry_t(&all_entries_0);
                        }
                        _fx_free_R13Ast__deffun_t(&v_269);
                     }
                     else {
                        need_to_check_0 = true;
                     }
                     FX_CHECK_EXN(_fx_catch_106);

                  _fx_catch_106: ;
                     _fx_free_N14Ast__id_info_t(&v_268);
                     goto _fx_endmatch_24;
                  }
               }
               need_to_check_0 = true;

            _fx_endmatch_24: ;
               FX_CHECK_EXN(_fx_catch_107);

            _fx_catch_107: ;
               if (v_267) {
                  _fx_free_N10Ast__typ_t(&v_267);
               }
               if (v_266) {
                  _fx_free_N10Ast__exp_t(&v_266);
               }
               if (v_265) {
                  _fx_free_N10Ast__exp_t(&v_265);
               }
               goto _fx_endmatch_25;
            }
            need_to_check_0 = true;

         _fx_endmatch_25: ;
            FX_CHECK_EXN(_fx_catch_108);
            if (need_to_check_0) {
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     a_5, &env_2, sc_2, &v_257, 0), _fx_catch_108);
               _fx_make_T2N10Ast__exp_tB(v_257, true, &t_8);
            }
            else {
               _fx_make_T2N10Ast__exp_tB(a_5, false, &t_8);
            }
            _fx_LT2N10Ast__exp_tB node_5 = 0;
            FX_CALL(_fx_cons_LT2N10Ast__exp_tB(&t_8, 0, false, &node_5), _fx_catch_108);
            FX_LIST_APPEND(new_args_0, lstend_5, node_5);

         _fx_catch_108: ;
            if (v_257) {
               _fx_free_N10Ast__exp_t(&v_257);
            }
            _fx_free_T2N10Ast__exp_tB(&t_8);
            _fx_free_R13Ast__deffun_t(&v_256);
            FX_CHECK_EXN(_fx_catch_117);
         }
         _fx_N10Ast__exp_t new_f_0 = 0;
         _fx_N10Ast__typ_t v_273 = 0;
         _fx_N10Ast__typ_t v_274 = 0;
         _fx_LT2N10Ast__exp_tB new_args_1 = 0;
         _fx_LN10Ast__exp_t new_args_2 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               f_2, &env_2, sc_2, &new_f_0, 0), _fx_catch_112);
         FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(new_f_0, &v_273, 0), _fx_catch_112);
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(v_273, &v_274, 0), _fx_catch_112);
         if (FX_REC_VARIANT_TAG(v_274) == 14) {
            _fx_N10Ast__typ_t last_typ_0 = 0;
            _fx_N10Ast__exp_t v_275 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_276 = {0};
            _fx_N10Ast__exp_t mkrec_0 = 0;
            _fx_T2N10Ast__exp_tB v_277 = {0};
            _fx_LT2N10Ast__exp_tB v_278 = 0;
            _fx_LN10Ast__typ_t argtyps_1 = v_274->u.TypFun.t0;
            int_ v_279;
            FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(argtyps_1, &v_279, 0), _fx_catch_109);
            int_ v_280;
            FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LT2N10Ast__exp_tB(new_args_0, &v_280, 0), _fx_catch_109);
            if (v_279 == v_280) {
               FX_COPY_PTR(new_args_0, &new_args_1);
            }
            else {
               int_ v_281;
               FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(argtyps_1, &v_281, 0), _fx_catch_109);
               int_ v_282;
               FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LT2N10Ast__exp_tB(new_args_0, &v_282, 0), _fx_catch_109);
               FX_CALL(_fx_F6assertv1B(v_281 == v_282 + 1, 0), _fx_catch_109);
               FX_CALL(_fx_M13Ast_typecheckFM4lastN10Ast__typ_t1LN10Ast__typ_t(argtyps_1, &last_typ_0, 0), _fx_catch_109);
               FX_CALL(_fx_M3AstFM6ExpNopN10Ast__exp_t1RM5loc_t(&eloc_0, &v_275), _fx_catch_109);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(last_typ_0, &eloc_0, &v_276);
               FX_CALL(
                  _fx_M3AstFM11ExpMkRecordN10Ast__exp_t3N10Ast__exp_tLT2RM4id_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_275, 0,
                     &v_276, &mkrec_0), _fx_catch_109);
               _fx_make_T2N10Ast__exp_tB(mkrec_0, true, &v_277);
               FX_CALL(_fx_cons_LT2N10Ast__exp_tB(&v_277, 0, true, &v_278), _fx_catch_109);
               FX_CALL(
                  _fx_M13Ast_typecheckFM7__add__LT2N10Ast__exp_tB2LT2N10Ast__exp_tBLT2N10Ast__exp_tB(new_args_0, v_278,
                     &new_args_1, 0), _fx_catch_109);
            }

         _fx_catch_109: ;
            if (v_278) {
               _fx_free_LT2N10Ast__exp_tB(&v_278);
            }
            _fx_free_T2N10Ast__exp_tB(&v_277);
            if (mkrec_0) {
               _fx_free_N10Ast__exp_t(&mkrec_0);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_276);
            if (v_275) {
               _fx_free_N10Ast__exp_t(&v_275);
            }
            if (last_typ_0) {
               _fx_free_N10Ast__typ_t(&last_typ_0);
            }
         }
         else {
            FX_COPY_PTR(new_args_0, &new_args_1);
         }
         FX_CHECK_EXN(_fx_catch_112);
         _fx_LN10Ast__exp_t lstend_6 = 0;
         _fx_LT2N10Ast__exp_tB lst_8 = new_args_1;
         for (; lst_8; lst_8 = lst_8->tl) {
            _fx_N10Ast__exp_t e_6 = 0;
            _fx_N10Ast__exp_t res_35 = 0;
            _fx_T2N10Ast__exp_tB* __pat___1 = &lst_8->hd;
            FX_COPY_PTR(__pat___1->t0, &e_6);
            if (__pat___1->t1 == true) {
               FX_COPY_PTR(e_6, &res_35);
            }
            else {
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     e_6, &env_2, sc_2, &res_35, 0), _fx_catch_110);

            _fx_catch_110: ;
            }
            FX_CHECK_EXN(_fx_catch_111);
            _fx_LN10Ast__exp_t node_6 = 0;
            FX_CALL(_fx_cons_LN10Ast__exp_t(res_35, 0, false, &node_6), _fx_catch_111);
            FX_LIST_APPEND(new_args_2, lstend_6, node_6);

         _fx_catch_111: ;
            if (res_35) {
               _fx_free_N10Ast__exp_t(&res_35);
            }
            if (e_6) {
               _fx_free_N10Ast__exp_t(&e_6);
            }
            FX_CHECK_EXN(_fx_catch_112);
         }
         FX_CALL(
            _fx_M3AstFM7ExpCallN10Ast__exp_t3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_f_0, new_args_2, &ctx_0,
               &result_34), _fx_catch_112);

      _fx_catch_112: ;
         if (new_f_0) {
            _fx_free_N10Ast__exp_t(&new_f_0);
         }
         if (v_273) {
            _fx_free_N10Ast__typ_t(&v_273);
         }
         if (v_274) {
            _fx_free_N10Ast__typ_t(&v_274);
         }
         if (new_args_1) {
            _fx_free_LT2N10Ast__exp_tB(&new_args_1);
         }
         if (new_args_2) {
            _fx_free_LN10Ast__exp_t(&new_args_2);
         }
         if (fx_status < 0) {
            fx_exn_get_and_reset(fx_status, &exn_2);
            fx_status = 0;
            if (result_34) {
               _fx_free_N10Ast__exp_t(&result_34);
            }
            if (exn_2.tag == _FX_EXN_E17Ast__CompileError) {
               if (FX_REC_VARIANT_TAG(f0_0) == 21) {
                  _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_19 = &f0_0->u.ExpMem;
                  _fx_T2N10Ast__typ_tR10Ast__loc_t* mem_ctx_0 = &vcase_19->t2;
                  _fx_N10Ast__exp_t mem_f_exp_0 = vcase_19->t1;
                  if (FX_REC_VARIANT_TAG(mem_f_exp_0) == 7) {
                     _fx_N10Ast__exp_t v_283 = 0;
                     _fx_N10Ast__exp_t r_0 = 0;
                     _fx_N10Ast__typ_t r_t_0 = 0;
                     _fx_N10Ast__typ_t v_284 = 0;
                     fx_str_t mstr_0 = {0};
                     _fx_N10Ast__exp_t new_f_1 = 0;
                     _fx_N10Ast__typ_t v_285 = 0;
                     _fx_T2N10Ast__typ_tR10Ast__loc_t v_286 = {0};
                     _fx_N10Ast__exp_t v_287 = 0;
                     _fx_LN10Ast__exp_t v_288 = 0;
                     _fx_N10Ast__exp_t new_exp_0 = 0;
                     _fx_N10Ast__exp_t r0_0 = vcase_19->t0;
                     FX_CALL(_fx_M3AstFM7dup_expN10Ast__exp_t1N10Ast__exp_t(r0_0, &v_283, 0), _fx_catch_115);
                     FX_CALL(
                        _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                           v_283, &env_2, sc_2, &r_0, 0), _fx_catch_115);
                     FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(r_0, &r_t_0, 0), _fx_catch_115);
                     FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(r_t_0, &v_284, 0), _fx_catch_115);
                     int tag_10 = FX_REC_VARIANT_TAG(v_284);
                     if (tag_10 == 15) {
                        fx_str_t slit_114 = FX_MAKE_STR("List"); fx_copy_str(&slit_114, &mstr_0);
                     }
                     else if (tag_10 == 16) {
                        fx_str_t slit_115 = FX_MAKE_STR("Vector"); fx_copy_str(&slit_115, &mstr_0);
                     }
                     else if (tag_10 == 10) {
                        fx_str_t slit_116 = FX_MAKE_STR("String"); fx_copy_str(&slit_116, &mstr_0);
                     }
                     else if (tag_10 == 11) {
                        fx_str_t slit_117 = FX_MAKE_STR("Char"); fx_copy_str(&slit_117, &mstr_0);
                     }
                     else if (tag_10 == 19) {
                        fx_str_t slit_118 = FX_MAKE_STR("Array"); fx_copy_str(&slit_118, &mstr_0);
                     }
                     else if (tag_10 == 24) {
                        _fx_N14Ast__id_info_t v_289 = {0};
                        _fx_R17Ast__defvariant_t v_290 = {0};
                        FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&v_284->u.TypApp.t1, &eloc_0, &v_289, 0),
                           _fx_catch_114);
                        if (v_289.tag == 6) {
                           _fx_copy_R17Ast__defvariant_t(&v_289.u.IdVariant->data, &v_290);
                           int_ m_0 = v_290.dvar_flags.var_flag_class_from;
                           if (m_0 > 0) {
                              _fx_R9Ast__id_t v_291;
                              FX_CALL(_fx_M3AstFM15get_module_nameRM4id_t1i(m_0, &v_291, 0), _fx_catch_113);
                              FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_291, &mstr_0, 0), _fx_catch_113);

                           _fx_catch_113: ;
                              goto _fx_endmatch_26;
                           }
                        }
                        fx_str_t slit_119 = FX_MAKE_STR("");
                        fx_copy_str(&slit_119, &mstr_0);

                     _fx_endmatch_26: ;
                        FX_CHECK_EXN(_fx_catch_114);

                     _fx_catch_114: ;
                        _fx_free_R17Ast__defvariant_t(&v_290);
                        _fx_free_N14Ast__id_info_t(&v_289);
                     }
                     else {
                        fx_str_t slit_120 = FX_MAKE_STR(""); fx_copy_str(&slit_120, &mstr_0);
                     }
                     FX_CHECK_EXN(_fx_catch_115);
                     bool v_292;
                     fx_str_t slit_121 = FX_MAKE_STR("Builtins");
                     v_292 = _fx_F6__eq__B2SS(&mstr_0, &slit_121, 0);
                     if (v_292) {
                        FX_COPY_PTR(mem_f_exp_0, &new_f_1);
                     }
                     else {
                        _fx_R9Ast__id_t m_id_0;
                        if (FX_STR_LENGTH(mstr_0) != 0) {
                           FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&mstr_0, &m_id_0, 0), _fx_catch_115);
                        }
                        else {
                           FX_THROW(&exn_2, false, _fx_catch_115);
                        }
                        _fx_R10Ast__loc_t floc_1 = mem_ctx_0->t1;
                        FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_285, 0), _fx_catch_115);
                        _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_285, &floc_1, &v_286);
                        FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&m_id_0, &v_286, &v_287),
                           _fx_catch_115);
                        FX_CALL(
                           _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_287, mem_f_exp_0,
                              mem_ctx_0, &new_f_1), _fx_catch_115);
                     }
                     FX_CALL(_fx_cons_LN10Ast__exp_t(r0_0, args0_0, true, &v_288), _fx_catch_115);
                     FX_CALL(
                        _fx_M3AstFM7ExpCallN10Ast__exp_t3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_f_1, v_288,
                           &ctx_0, &new_exp_0), _fx_catch_115);
                     FX_CALL(
                        _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                           new_exp_0, &env_2, sc_2, &result_34, 0), _fx_catch_115);

                  _fx_catch_115: ;
                     if (new_exp_0) {
                        _fx_free_N10Ast__exp_t(&new_exp_0);
                     }
                     if (v_288) {
                        _fx_free_LN10Ast__exp_t(&v_288);
                     }
                     if (v_287) {
                        _fx_free_N10Ast__exp_t(&v_287);
                     }
                     _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_286);
                     if (v_285) {
                        _fx_free_N10Ast__typ_t(&v_285);
                     }
                     if (new_f_1) {
                        _fx_free_N10Ast__exp_t(&new_f_1);
                     }
                     FX_FREE_STR(&mstr_0);
                     if (v_284) {
                        _fx_free_N10Ast__typ_t(&v_284);
                     }
                     if (r_t_0) {
                        _fx_free_N10Ast__typ_t(&r_t_0);
                     }
                     if (r_0) {
                        _fx_free_N10Ast__exp_t(&r_0);
                     }
                     if (v_283) {
                        _fx_free_N10Ast__exp_t(&v_283);
                     }
                     goto _fx_endmatch_27;
                  }
               }
               FX_THROW(&exn_2, false, _fx_catch_116);

            _fx_endmatch_27: ;
               FX_CHECK_EXN(_fx_catch_116);

            _fx_catch_116: ;
            }
            else {
               FX_RETHROW(&exn_2, _fx_catch_117);
            }
            FX_CHECK_EXN(_fx_catch_117);
         }
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_34, &result_0);
         FX_BREAK(_fx_catch_117);

      _fx_catch_117: ;
         fx_free_exn(&exn_2);
         if (result_34) {
            _fx_free_N10Ast__exp_t(&result_34);
         }
         if (new_args_0) {
            _fx_free_LT2N10Ast__exp_tB(&new_args_0);
         }
         FX_FREE_STR(&v_255);
         FX_FREE_STR(&v_254);
         FX_FREE_STR(&v_253);
         FX_FREE_STR(&v_252);
         FX_FREE_STR(&v_251);
         if (f_real_typ_0) {
            _fx_free_N10Ast__typ_t(&f_real_typ_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_250);
         if (f_expected_typ_0) {
            _fx_free_N10Ast__typ_t(&f_expected_typ_0);
         }
         if (arg_typs_0) {
            _fx_free_LN10Ast__typ_t(&arg_typs_0);
         }
         if (args_5) {
            _fx_free_LN10Ast__exp_t(&args_5);
         }
         FX_FREE_FP(&dup_exp_0);
         if (f_2) {
            _fx_free_N10Ast__exp_t(&f_2);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 19) {
         _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t v_293 = {0};
         _fx_N10Ast__exp_t arr_0 = 0;
         _fx_N10Ast__exp_t new_arr_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_294 = {0};
         _fx_N10Ast__typ_t new_atyp_0 = 0;
         fx_exn_t v_295 = {0};
         _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_20 =
            &e_2->u.ExpAt;
         _fx_LN10Ast__exp_t idxs_0 = vcase_20->t3;
         FX_CALL(
            _fx_M13Ast_typecheckFM10check_attrT3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t4N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tR10Ast__loc_t(
               vcase_20->t0, &vcase_20->t1, &vcase_20->t2, &eloc_0, &v_293, 0), _fx_catch_134);
         FX_COPY_PTR(v_293.t0, &arr_0);
         _fx_N13Ast__border_t border_0 = v_293.t1;
         _fx_N18Ast__interpolate_t interp_0 = v_293.t2;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               arr_0, &env_2, sc_2, &new_arr_0, 0), _fx_catch_134);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_arr_0, &v_294, 0), _fx_catch_134);
         FX_COPY_PTR(v_294.t0, &new_atyp_0);
         _fx_R10Ast__loc_t new_aloc_0 = v_294.t1;
         if (interp_0.tag != 1) {
            fx_str_t slit_122 = FX_MAKE_STR("inter-element interpolation is not supported yet");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_122, &v_295, 0), _fx_catch_134);
            FX_THROW(&v_295, false, _fx_catch_134);
         }
         if (idxs_0 != 0) {
            if (idxs_0->tl == 0) {
               _fx_N10Ast__exp_t v_296 = idxs_0->hd;
               if (FX_REC_VARIANT_TAG(v_296) == 5) {
                  _fx_T4Nt6option1N10Ast__exp_tNt6option1N10Ast__exp_tNt6option1N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t*
                     vcase_21 = &v_296->u.ExpRange;
                  if ((vcase_21->t0 != 0) + 1 == 1) {
                     if ((vcase_21->t1 != 0) + 1 == 1) {
                        if ((vcase_21->t2 != 0) + 1 == 1) {
                           _fx_N10Ast__exp_t v_297 = 0;
                           _fx_N10Ast__exp_t new_idx_0 = 0;
                           _fx_N10Ast__typ_t v_298 = 0;
                           FX_CALL(_fx_M13Ast_typecheckFM2hdN10Ast__exp_t1LN10Ast__exp_t(idxs_0, &v_297, 0), _fx_catch_122);
                           FX_CALL(
                              _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                 v_297, &env_2, sc_2, &new_idx_0, 0), _fx_catch_122);
                           FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(new_atyp_0, &v_298, 0), _fx_catch_122);
                           int tag_11 = FX_REC_VARIANT_TAG(v_298);
                           if (tag_11 == 19) {
                              _fx_N10Ast__typ_t v_299 = 0;
                              _fx_LN10Ast__exp_t v_300 = 0;
                              _fx_N10Ast__exp_t result_35 = 0;
                              FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(1, v_298->u.TypArray.t1, &v_299),
                                 _fx_catch_118);
                              fx_str_t slit_123 =
                                 FX_MAKE_STR(
                                    "the result of flatten operation ([:]) applied to N-D array must be 1D array with elements of the same type as input array");
                              FX_CALL(
                                 _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_299, &eloc_0,
                                    &slit_123, 0), _fx_catch_118);
                              FX_CALL(_fx_cons_LN10Ast__exp_t(new_idx_0, 0, true, &v_300), _fx_catch_118);
                              FX_CALL(
                                 _fx_M3AstFM5ExpAtN10Ast__exp_t5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    new_arr_0, &_fx_g25Ast_typecheck__BorderNone, &_fx_g25Ast_typecheck__InterpNone, v_300,
                                    &ctx_0, &result_35), _fx_catch_118);
                              _fx_free_N10Ast__exp_t(&result_0);
                              FX_COPY_PTR(result_35, &result_0);
                              FX_BREAK(_fx_catch_118);

                           _fx_catch_118: ;
                              if (result_35) {
                                 _fx_free_N10Ast__exp_t(&result_35);
                              }
                              if (v_300) {
                                 _fx_free_LN10Ast__exp_t(&v_300);
                              }
                              if (v_299) {
                                 _fx_free_N10Ast__typ_t(&v_299);
                              }
                           }
                           else if (tag_11 == 16) {
                              _fx_N10Ast__typ_t v_301 = 0;
                              _fx_LN10Ast__exp_t v_302 = 0;
                              _fx_N10Ast__exp_t result_36 = 0;
                              FX_CALL(_fx_M3AstFM9TypVectorN10Ast__typ_t1N10Ast__typ_t(v_298->u.TypVector, &v_301),
                                 _fx_catch_119);
                              fx_str_t slit_124 =
                                 FX_MAKE_STR(
                                    "the result of flatten operation ([:]) applied to vector must be a vector of the same type");
                              FX_CALL(
                                 _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_301, &eloc_0,
                                    &slit_124, 0), _fx_catch_119);
                              FX_CALL(_fx_cons_LN10Ast__exp_t(new_idx_0, 0, true, &v_302), _fx_catch_119);
                              FX_CALL(
                                 _fx_M3AstFM5ExpAtN10Ast__exp_t5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    new_arr_0, &_fx_g25Ast_typecheck__BorderNone, &_fx_g25Ast_typecheck__InterpNone, v_302,
                                    &ctx_0, &result_36), _fx_catch_119);
                              _fx_free_N10Ast__exp_t(&result_0);
                              FX_COPY_PTR(result_36, &result_0);
                              FX_BREAK(_fx_catch_119);

                           _fx_catch_119: ;
                              if (result_36) {
                                 _fx_free_N10Ast__exp_t(&result_36);
                              }
                              if (v_302) {
                                 _fx_free_LN10Ast__exp_t(&v_302);
                              }
                              if (v_301) {
                                 _fx_free_N10Ast__typ_t(&v_301);
                              }
                           }
                           else if (tag_11 == 10) {
                              fx_str_t slit_125 =
                                 FX_MAKE_STR("the result of flatten operation ([:]) applied to a string must be string");
                              FX_CALL(
                                 _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0,
                                    _fx_g24Ast_typecheck__TypString, &eloc_0, &slit_125, 0), _fx_catch_120);
                              _fx_free_N10Ast__exp_t(&result_0);
                              FX_COPY_PTR(new_arr_0, &result_0);
                              FX_BREAK(_fx_catch_120);

                           _fx_catch_120: ;
                           }
                           else {
                              fx_exn_t v_303 = {0};
                              fx_str_t slit_126 = FX_MAKE_STR("the argument of the flatten operation must be an array");
                              FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_126, &v_303, 0), _fx_catch_121);
                              FX_THROW(&v_303, false, _fx_catch_121);

                           _fx_catch_121: ;
                              fx_free_exn(&v_303);
                           }
                           FX_CHECK_EXN(_fx_catch_122);

                        _fx_catch_122: ;
                           if (v_298) {
                              _fx_free_N10Ast__typ_t(&v_298);
                           }
                           if (new_idx_0) {
                              _fx_free_N10Ast__exp_t(&new_idx_0);
                           }
                           if (v_297) {
                              _fx_free_N10Ast__exp_t(&v_297);
                           }
                           goto _fx_endmatch_29;
                        }
                     }
                  }
               }
            }
         }
         _fx_T4LN10Ast__exp_tiii __fold_result___2 = {0};
         _fx_LN10Ast__exp_t idxs_1 = 0;
         _fx_T4LN10Ast__exp_tiii v_304 = {0};
         _fx_LN10Ast__exp_t new_idxs_0 = 0;
         _fx_N10Ast__typ_t v_305 = 0;
         _fx_LN10Ast__exp_t v_306 = 0;
         _fx_N10Ast__exp_t result_37 = 0;
         _fx_make_T4LN10Ast__exp_tiii(0, 0, 0, 0, &__fold_result___2);
         FX_COPY_PTR(idxs_0, &idxs_1);
         _fx_LN10Ast__exp_t lst_9 = idxs_1;
         for (; lst_9; lst_9 = lst_9->tl) {
            _fx_T4LN10Ast__exp_tiii v_307 = {0};
            _fx_LN10Ast__exp_t new_idxs_1 = 0;
            _fx_N10Ast__exp_t new_idx_1 = 0;
            _fx_T4LN10Ast__exp_tiii v_308 = {0};
            _fx_N10Ast__exp_t idx_1 = lst_9->hd;
            _fx_copy_T4LN10Ast__exp_tiii(&__fold_result___2, &v_307);
            FX_COPY_PTR(v_307.t0, &new_idxs_1);
            int_ ndims_0 = v_307.t1;
            int_ nfirst_scalars_0 = v_307.t2;
            int_ nranges_0 = v_307.t3;
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  idx_1, &env_2, sc_2, &new_idx_1, 0), _fx_catch_125);
            if (FX_REC_VARIANT_TAG(new_idx_1) == 5) {
               _fx_LN10Ast__exp_t v_309 = 0;
               FX_CALL(_fx_cons_LN10Ast__exp_t(new_idx_1, new_idxs_1, true, &v_309), _fx_catch_123);
               _fx_make_T4LN10Ast__exp_tiii(v_309, ndims_0 + 1, nfirst_scalars_0, nranges_0 + 1, &v_308);

            _fx_catch_123: ;
               if (v_309) {
                  _fx_free_LN10Ast__exp_t(&v_309);
               }
            }
            else {
               _fx_N10Ast__typ_t v_310 = 0;
               _fx_N10Ast__typ_t v_311 = 0;
               _fx_N10Ast__typ_t v_312 = 0;
               _fx_N10Ast__typ_t v_313 = 0;
               _fx_N10Ast__typ_t v_314 = 0;
               _fx_N10Ast__typ_t v_315 = 0;
               _fx_N10Ast__typ_t v_316 = 0;
               _fx_N10Ast__typ_t v_317 = 0;
               _fx_LN10Ast__typ_t v_318 = 0;
               _fx_LN10Ast__typ_t possible_idx_typs_0 = 0;
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_319 = {0};
               _fx_N10Ast__typ_t new_ityp_0 = 0;
               fx_exn_t v_320 = {0};
               _fx_LN10Ast__exp_t v_321 = 0;
               FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(8, &v_310), _fx_catch_124);
               FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(8, &v_311), _fx_catch_124);
               FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(16, &v_312), _fx_catch_124);
               FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(16, &v_313), _fx_catch_124);
               FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(32, &v_314), _fx_catch_124);
               FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(32, &v_315), _fx_catch_124);
               FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(64, &v_316), _fx_catch_124);
               FX_CALL(_fx_M3AstFM7TypSIntN10Ast__typ_t1i(64, &v_317), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_317, 0, true, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_316, v_318, false, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_315, v_318, false, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_314, v_318, false, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_313, v_318, false, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_312, v_318, false, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_311, v_318, false, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(v_310, v_318, false, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g22Ast_typecheck__TypBool, v_318, false, &v_318), _fx_catch_124);
               FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, v_318, true, &possible_idx_typs_0), _fx_catch_124);
               FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(new_idx_1, &v_319, 0), _fx_catch_124);
               FX_COPY_PTR(v_319.t0, &new_ityp_0);
               _fx_R10Ast__loc_t new_iloc_0 = v_319.t1;
               bool v_322;
               FX_CALL(
                  _fx_M13Ast_typecheckFM26idx_type_is_correct_scalarB4N10Ast__typ_tR10Ast__loc_tN18Ast__interpolate_tLN10Ast__typ_t(
                     new_ityp_0, &new_iloc_0, &interp_0, possible_idx_typs_0, &v_322, 0), _fx_catch_124);
               int_ dim_inc_0;
               if (v_322) {
                  dim_inc_0 = 1;
               }
               else {
                  _fx_T2Bi v_323;
                  FX_CALL(
                     _fx_M13Ast_typecheckFM25idx_type_is_correct_tupleT2Bi5N10Ast__typ_tR10Ast__loc_tLN10Ast__exp_tN18Ast__interpolate_tLN10Ast__typ_t(
                        new_ityp_0, &new_iloc_0, idxs_0, &interp_0, possible_idx_typs_0, &v_323, 0), _fx_catch_124);
                  bool is_correct_tuple_0 = v_323.t0;
                  int_ dim_inc_1 = v_323.t1;
                  if (is_correct_tuple_0) {
                     dim_inc_0 = dim_inc_1;
                  }
                  else {
                     fx_str_t slit_127 =
                        FX_MAKE_STR(
                           "each scalar index in array access op must have some integer type or bool; in the case of interpolation it can also be float or double");
                     FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&new_iloc_0, &slit_127, &v_320, 0), _fx_catch_124);
                     FX_THROW(&v_320, false, _fx_catch_124);
                  }
               }
               int_ nfirst_scalars_1;
               if (nranges_0 == 0) {
                  nfirst_scalars_1 = nfirst_scalars_0 + dim_inc_0;
               }
               else {
                  nfirst_scalars_1 = nfirst_scalars_0;
               }
               FX_CALL(_fx_cons_LN10Ast__exp_t(new_idx_1, new_idxs_1, true, &v_321), _fx_catch_124);
               _fx_make_T4LN10Ast__exp_tiii(v_321, ndims_0 + dim_inc_0, nfirst_scalars_1, nranges_0, &v_308);

            _fx_catch_124: ;
               if (v_321) {
                  _fx_free_LN10Ast__exp_t(&v_321);
               }
               fx_free_exn(&v_320);
               if (new_ityp_0) {
                  _fx_free_N10Ast__typ_t(&new_ityp_0);
               }
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_319);
               if (possible_idx_typs_0) {
                  _fx_free_LN10Ast__typ_t(&possible_idx_typs_0);
               }
               if (v_318) {
                  _fx_free_LN10Ast__typ_t(&v_318);
               }
               if (v_317) {
                  _fx_free_N10Ast__typ_t(&v_317);
               }
               if (v_316) {
                  _fx_free_N10Ast__typ_t(&v_316);
               }
               if (v_315) {
                  _fx_free_N10Ast__typ_t(&v_315);
               }
               if (v_314) {
                  _fx_free_N10Ast__typ_t(&v_314);
               }
               if (v_313) {
                  _fx_free_N10Ast__typ_t(&v_313);
               }
               if (v_312) {
                  _fx_free_N10Ast__typ_t(&v_312);
               }
               if (v_311) {
                  _fx_free_N10Ast__typ_t(&v_311);
               }
               if (v_310) {
                  _fx_free_N10Ast__typ_t(&v_310);
               }
            }
            FX_CHECK_EXN(_fx_catch_125);
            _fx_free_T4LN10Ast__exp_tiii(&__fold_result___2);
            _fx_copy_T4LN10Ast__exp_tiii(&v_308, &__fold_result___2);

         _fx_catch_125: ;
            _fx_free_T4LN10Ast__exp_tiii(&v_308);
            if (new_idx_1) {
               _fx_free_N10Ast__exp_t(&new_idx_1);
            }
            if (new_idxs_1) {
               _fx_free_LN10Ast__exp_t(&new_idxs_1);
            }
            _fx_free_T4LN10Ast__exp_tiii(&v_307);
            FX_CHECK_EXN(_fx_catch_133);
         }
         _fx_copy_T4LN10Ast__exp_tiii(&__fold_result___2, &v_304);
         FX_COPY_PTR(v_304.t0, &new_idxs_0);
         int_ ndims_1 = v_304.t1;
         int_ nfirst_scalars_2 = v_304.t2;
         int_ nranges_1 = v_304.t3;
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(new_atyp_0, &v_305, 0), _fx_catch_133);
         if (nranges_1 == 0) {
            if (ndims_1 == 1) {
               if (FX_REC_VARIANT_TAG(v_305) == 10) {
                  fx_str_t slit_128 = FX_MAKE_STR("indexing string should give a char");
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0,
                        _fx_g22Ast_typecheck__TypChar, &new_aloc_0, &slit_128, 0), _fx_catch_126);

               _fx_catch_126: ;
                  goto _fx_endmatch_28;
               }
            }
         }
         if (nranges_1 == 1) {
            if (ndims_1 == 1) {
               if (FX_REC_VARIANT_TAG(v_305) == 10) {
                  fx_str_t slit_129 = FX_MAKE_STR("indexing string with a range should give a string");
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0,
                        _fx_g24Ast_typecheck__TypString, &new_aloc_0, &slit_129, 0), _fx_catch_127);

               _fx_catch_127: ;
                  goto _fx_endmatch_28;
               }
            }
         }
         if (nranges_1 == 0) {
            if (ndims_1 == 1) {
               if (FX_REC_VARIANT_TAG(v_305) == 16) {
                  fx_str_t slit_130 =
                     FX_MAKE_STR(
                        "incorrect type of the vector element access operation; it gives \'{typ2str(et)}\', but \'{typ2str(etyp)}\' is expected");
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_305->u.TypVector,
                        &new_aloc_0, &slit_130, 0), _fx_catch_128);

               _fx_catch_128: ;
                  goto _fx_endmatch_28;
               }
            }
         }
         if (nranges_1 == 1) {
            if (ndims_1 == 1) {
               if (FX_REC_VARIANT_TAG(v_305) == 16) {
                  _fx_N10Ast__typ_t v_324 = 0;
                  FX_CALL(_fx_M3AstFM9TypVectorN10Ast__typ_t1N10Ast__typ_t(v_305->u.TypVector, &v_324), _fx_catch_129);
                  fx_str_t slit_131 =
                     FX_MAKE_STR(
                        "incorrect type of the vector range access operation; it gives \'{typ2str(TypVector(et))}\', but \'{typ2str(etyp)}\' is expected");
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_324, &new_aloc_0,
                        &slit_131, 0), _fx_catch_129);

               _fx_catch_129: ;
                  if (v_324) {
                     _fx_free_N10Ast__typ_t(&v_324);
                  }
                  goto _fx_endmatch_28;
               }
            }
         }
         _fx_N10Ast__typ_t et_1 = 0;
         _fx_N10Ast__typ_t v_325 = 0;
         fx_str_t v_326 = {0};
         fx_str_t v_327 = {0};
         _fx_N10Ast__typ_t v_328 = 0;
         fx_str_t v_329 = {0};
         fx_str_t v_330 = {0};
         fx_str_t v_331 = {0};
         _fx_N10Ast__typ_t v_332 = 0;
         FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&et_1, 0), _fx_catch_131);
         FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(ndims_1, et_1, &v_325), _fx_catch_131);
         FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(new_atyp_0, &v_326, 0), _fx_catch_131);
         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_326, &v_327, 0), _fx_catch_131);
         FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(ndims_1, et_1, &v_328), _fx_catch_131);
         FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(v_328, &v_329, 0), _fx_catch_131);
         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_329, &v_330, 0), _fx_catch_131);
         fx_str_t slit_132 = FX_MAKE_STR("the array type/dimensionality \'");
         fx_str_t slit_133 = FX_MAKE_STR("\' does not match the expected type/dimensionality \'");
         fx_str_t slit_134 = FX_MAKE_STR("\'");
         {
            const fx_str_t strs_15[] = { slit_132, v_327, slit_133, v_330, slit_134 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_15, 5, &v_331), _fx_catch_131);
         }
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(new_atyp_0, v_325, &new_aloc_0, &v_331, 0),
            _fx_catch_131);
         if (border_0.tag != 1) {
            fx_exn_t v_333 = {0};
            int_ elem_sz_0;
            FX_CALL(_fx_M3AstFM20get_numeric_typ_sizei2N10Ast__typ_tB(et_1, true, &elem_sz_0, 0), _fx_catch_130);
            if (!(bool)((0 < elem_sz_0) & (elem_sz_0 <= 256))) {
               fx_str_t slit_135 =
                  FX_MAKE_STR(
                     "border extrapolation is used with an array, which elements are too large ({elem_sz} bytes) or have unsupported type \'{typ2str(et)\'");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_135, &v_333, 0), _fx_catch_130);
               FX_THROW(&v_333, false, _fx_catch_130);
            }

         _fx_catch_130: ;
            fx_free_exn(&v_333);
         }
         FX_CHECK_EXN(_fx_catch_131);
         if (nranges_1 == 0) {
            fx_str_t slit_136 = FX_MAKE_STR("the type of array access expression does not match the array element type");
            FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, et_1, &eloc_0, &slit_136, 0),
               _fx_catch_131);
         }
         else {
            FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(ndims_1 - nfirst_scalars_2, et_1, &v_332), _fx_catch_131);
            fx_str_t slit_137 =
               FX_MAKE_STR(
                  "the number of ranges does not match dimensionality of the result, or the element type is incorrect");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_332, &eloc_0, &slit_137, 0),
               _fx_catch_131);
         }

      _fx_catch_131: ;
         if (v_332) {
            _fx_free_N10Ast__typ_t(&v_332);
         }
         FX_FREE_STR(&v_331);
         FX_FREE_STR(&v_330);
         FX_FREE_STR(&v_329);
         if (v_328) {
            _fx_free_N10Ast__typ_t(&v_328);
         }
         FX_FREE_STR(&v_327);
         FX_FREE_STR(&v_326);
         if (v_325) {
            _fx_free_N10Ast__typ_t(&v_325);
         }
         if (et_1) {
            _fx_free_N10Ast__typ_t(&et_1);
         }

      _fx_endmatch_28: ;
         FX_CHECK_EXN(_fx_catch_133);
         if (interp_0.tag != 1) {
            fx_exn_t v_334 = {0};
            fx_str_t slit_138 = FX_MAKE_STR("element interpolation is not supported yet");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_138, &v_334, 0), _fx_catch_132);
            FX_THROW(&v_334, false, _fx_catch_132);

         _fx_catch_132: ;
            fx_free_exn(&v_334);
         }
         FX_CHECK_EXN(_fx_catch_133);
         FX_CALL(_fx_M13Ast_typecheckFM3revLN10Ast__exp_t1LN10Ast__exp_t(new_idxs_0, &v_306, 0), _fx_catch_133);
         FX_CALL(
            _fx_M3AstFM5ExpAtN10Ast__exp_t5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
               new_arr_0, &border_0, &interp_0, v_306, &ctx_0, &result_37), _fx_catch_133);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_37, &result_0);
         FX_BREAK(_fx_catch_133);

      _fx_catch_133: ;
         if (result_37) {
            _fx_free_N10Ast__exp_t(&result_37);
         }
         if (v_306) {
            _fx_free_LN10Ast__exp_t(&v_306);
         }
         if (v_305) {
            _fx_free_N10Ast__typ_t(&v_305);
         }
         if (new_idxs_0) {
            _fx_free_LN10Ast__exp_t(&new_idxs_0);
         }
         _fx_free_T4LN10Ast__exp_tiii(&v_304);
         if (idxs_1) {
            _fx_free_LN10Ast__exp_t(&idxs_1);
         }
         _fx_free_T4LN10Ast__exp_tiii(&__fold_result___2);

      _fx_endmatch_29: ;
         FX_CHECK_EXN(_fx_catch_134);

      _fx_catch_134: ;
         fx_free_exn(&v_295);
         if (new_atyp_0) {
            _fx_free_N10Ast__typ_t(&new_atyp_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_294);
         if (new_arr_0) {
            _fx_free_N10Ast__exp_t(&new_arr_0);
         }
         if (arr_0) {
            _fx_free_N10Ast__exp_t(&arr_0);
         }
         _fx_free_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&v_293);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 23) {
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_335 = {0};
         _fx_N10Ast__typ_t ctyp_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_336 = {0};
         _fx_N10Ast__typ_t typ1_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_337 = {0};
         _fx_N10Ast__typ_t typ2_0 = 0;
         _fx_N10Ast__exp_t new_c_0 = 0;
         _fx_N10Ast__exp_t new_e1_11 = 0;
         _fx_N10Ast__exp_t new_e2_6 = 0;
         _fx_N10Ast__exp_t result_38 = 0;
         _fx_T4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_22 = &e_2->u.ExpIf;
         _fx_N10Ast__exp_t e2_3 = vcase_22->t2;
         _fx_N10Ast__exp_t e1_4 = vcase_22->t1;
         _fx_N10Ast__exp_t c_0 = vcase_22->t0;
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(c_0, &v_335, 0), _fx_catch_137);
         FX_COPY_PTR(v_335.t0, &ctyp_0);
         _fx_R10Ast__loc_t cloc_0 = v_335.t1;
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_4, &v_336, 0), _fx_catch_137);
         FX_COPY_PTR(v_336.t0, &typ1_0);
         _fx_R10Ast__loc_t loc1_0 = v_336.t1;
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e2_3, &v_337, 0), _fx_catch_137);
         FX_COPY_PTR(v_337.t0, &typ2_0);
         _fx_R10Ast__loc_t loc2_0 = v_337.t1;
         fx_str_t slit_139 = FX_MAKE_STR("if() condition should have \'bool\' type");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(ctyp_0, _fx_g22Ast_typecheck__TypBool,
               &cloc_0, &slit_139, 0), _fx_catch_137);
         fx_str_t slit_140 = FX_MAKE_STR("if() expression should have the same type as its branches");
         FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(typ1_0, etyp_0, &loc1_0, &slit_140, 0),
            _fx_catch_137);
         bool v_338;
         FX_CALL(
            _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(typ2_0, etyp_0, &loc2_0, true, &v_338,
               0), _fx_catch_137);
         if (!v_338) {
            if (FX_REC_VARIANT_TAG(e2_3) == 1) {
               fx_exn_t v_339 = {0};
               fx_str_t slit_141 = FX_MAKE_STR("if() expression of non-void type has no \'else\' branch");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&loc2_0, &slit_141, &v_339, 0), _fx_catch_135);
               FX_THROW(&v_339, false, _fx_catch_135);

            _fx_catch_135: ;
               fx_free_exn(&v_339);
            }
            else {
               fx_str_t slit_142 = FX_MAKE_STR("if() expression should have the same type as its branches");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(typ2_0, etyp_0, &loc2_0, &slit_142, 0),
                  _fx_catch_136);

            _fx_catch_136: ;
            }
            FX_CHECK_EXN(_fx_catch_137);
         }
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               c_0, &env_2, sc_2, &new_c_0, 0), _fx_catch_137);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e1_4, &env_2, sc_2, &new_e1_11, 0), _fx_catch_137);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e2_3, &env_2, sc_2, &new_e2_6, 0), _fx_catch_137);
         FX_CALL(
            _fx_M3AstFM5ExpIfN10Ast__exp_t4N10Ast__exp_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_c_0, new_e1_11,
               new_e2_6, &ctx_0, &result_38), _fx_catch_137);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_38, &result_0);
         FX_BREAK(_fx_catch_137);

      _fx_catch_137: ;
         if (result_38) {
            _fx_free_N10Ast__exp_t(&result_38);
         }
         if (new_e2_6) {
            _fx_free_N10Ast__exp_t(&new_e2_6);
         }
         if (new_e1_11) {
            _fx_free_N10Ast__exp_t(&new_e1_11);
         }
         if (new_c_0) {
            _fx_free_N10Ast__exp_t(&new_c_0);
         }
         if (typ2_0) {
            _fx_free_N10Ast__typ_t(&typ2_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_337);
         if (typ1_0) {
            _fx_free_N10Ast__typ_t(&typ1_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_336);
         if (ctyp_0) {
            _fx_free_N10Ast__typ_t(&ctyp_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_335);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 24) {
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_340 = {0};
         _fx_N10Ast__typ_t ctyp_1 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_341 = {0};
         _fx_N10Ast__typ_t btyp_0 = 0;
         _fx_N10Ast__exp_t new_c_1 = 0;
         _fx_LN12Ast__scope_t loop_sc_0 = 0;
         _fx_N10Ast__exp_t new_body_0 = 0;
         _fx_N10Ast__exp_t result_39 = 0;
         _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t* vcase_23 = &e_2->u.ExpWhile;
         _fx_N10Ast__exp_t body_0 = vcase_23->t1;
         _fx_N10Ast__exp_t c_1 = vcase_23->t0;
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(c_1, &v_340, 0), _fx_catch_138);
         FX_COPY_PTR(v_340.t0, &ctyp_1);
         _fx_R10Ast__loc_t cloc_1 = v_340.t1;
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(body_0, &v_341, 0), _fx_catch_138);
         FX_COPY_PTR(v_341.t0, &btyp_0);
         _fx_R10Ast__loc_t bloc_0 = v_341.t1;
         fx_str_t slit_143 = FX_MAKE_STR("while() loop condition should have \'bool\' type");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(ctyp_1, _fx_g22Ast_typecheck__TypBool,
               &cloc_1, &slit_143, 0), _fx_catch_138);
         fx_str_t slit_144 = FX_MAKE_STR("while() loop body should have \'void\' type");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(btyp_0, _fx_g22Ast_typecheck__TypVoid,
               &bloc_0, &slit_144, 0), _fx_catch_138);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               c_1, &env_2, sc_2, &new_c_1, 0), _fx_catch_138);
         _fx_N12Ast__scope_t v_342;
         FX_CALL(_fx_M3AstFM14new_loop_scopeN12Ast__scope_t2iB(curr_m_idx_0, false, &v_342, 0), _fx_catch_138);
         FX_CALL(_fx_cons_LN12Ast__scope_t(&v_342, sc_2, true, &loop_sc_0), _fx_catch_138);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               body_0, &env_2, loop_sc_0, &new_body_0, 0), _fx_catch_138);
         FX_CALL(_fx_M3AstFM8ExpWhileN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tRM5loc_t(new_c_1, new_body_0, &eloc_0, &result_39),
            _fx_catch_138);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_39, &result_0);
         FX_BREAK(_fx_catch_138);

      _fx_catch_138: ;
         if (result_39) {
            _fx_free_N10Ast__exp_t(&result_39);
         }
         if (new_body_0) {
            _fx_free_N10Ast__exp_t(&new_body_0);
         }
         FX_FREE_LIST_SIMPLE(&loop_sc_0);
         if (new_c_1) {
            _fx_free_N10Ast__exp_t(&new_c_1);
         }
         if (btyp_0) {
            _fx_free_N10Ast__typ_t(&btyp_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_341);
         if (ctyp_1) {
            _fx_free_N10Ast__typ_t(&ctyp_1);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_340);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 25) {
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_343 = {0};
         _fx_N10Ast__typ_t ctyp_2 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_344 = {0};
         _fx_N10Ast__typ_t btyp_1 = 0;
         _fx_N10Ast__exp_t new_c_2 = 0;
         _fx_LN12Ast__scope_t loop_sc_1 = 0;
         _fx_N10Ast__exp_t new_body_1 = 0;
         _fx_N10Ast__exp_t result_40 = 0;
         _fx_T3N10Ast__exp_tN10Ast__exp_tR10Ast__loc_t* vcase_24 = &e_2->u.ExpDoWhile;
         _fx_N10Ast__exp_t c_2 = vcase_24->t1;
         _fx_N10Ast__exp_t body_1 = vcase_24->t0;
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(c_2, &v_343, 0), _fx_catch_139);
         FX_COPY_PTR(v_343.t0, &ctyp_2);
         _fx_R10Ast__loc_t cloc_2 = v_343.t1;
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(body_1, &v_344, 0), _fx_catch_139);
         FX_COPY_PTR(v_344.t0, &btyp_1);
         _fx_R10Ast__loc_t bloc_1 = v_344.t1;
         fx_str_t slit_145 = FX_MAKE_STR("do-while() loop condition should have \'bool\' type");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(ctyp_2, _fx_g22Ast_typecheck__TypBool,
               &cloc_2, &slit_145, 0), _fx_catch_139);
         fx_str_t slit_146 = FX_MAKE_STR("do-while() loop body should have \'void\' type");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(btyp_1, _fx_g22Ast_typecheck__TypVoid,
               &bloc_1, &slit_146, 0), _fx_catch_139);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               c_2, &env_2, sc_2, &new_c_2, 0), _fx_catch_139);
         _fx_N12Ast__scope_t v_345;
         FX_CALL(_fx_M3AstFM14new_loop_scopeN12Ast__scope_t2iB(curr_m_idx_0, false, &v_345, 0), _fx_catch_139);
         FX_CALL(_fx_cons_LN12Ast__scope_t(&v_345, sc_2, true, &loop_sc_1), _fx_catch_139);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               body_1, &env_2, loop_sc_1, &new_body_1, 0), _fx_catch_139);
         FX_CALL(
            _fx_M3AstFM10ExpDoWhileN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tRM5loc_t(new_body_1, new_c_2, &eloc_0, &result_40),
            _fx_catch_139);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_40, &result_0);
         FX_BREAK(_fx_catch_139);

      _fx_catch_139: ;
         if (result_40) {
            _fx_free_N10Ast__exp_t(&result_40);
         }
         if (new_body_1) {
            _fx_free_N10Ast__exp_t(&new_body_1);
         }
         FX_FREE_LIST_SIMPLE(&loop_sc_1);
         if (new_c_2) {
            _fx_free_N10Ast__exp_t(&new_c_2);
         }
         if (btyp_1) {
            _fx_free_N10Ast__typ_t(&btyp_1);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_344);
         if (ctyp_2) {
            _fx_free_N10Ast__typ_t(&ctyp_2);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_343);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 26) {
         fx_exn_t v_346 = {0};
         _fx_LN12Ast__scope_t for_sc_0 = 0;
         _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t
            v_347 = {0};
         _fx_LN10Ast__exp_t pre_code_0 = 0;
         _fx_LT2N10Ast__pat_tN10Ast__exp_t for_clauses_0 = 0;
         _fx_N10Ast__pat_t idx_pat_0 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_4 = {0};
         _fx_LN10Ast__exp_t code_0 = 0;
         _fx_LN10Ast__exp_t v_348 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_349 = {0};
         _fx_N10Ast__exp_t result_41 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_350 = {0};
         _fx_N10Ast__typ_t btyp_2 = 0;
         _fx_N10Ast__exp_t new_body_2 = 0;
         _fx_N10Ast__exp_t result_42 = 0;
         _fx_T5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tR10Ast__loc_t* vcase_25 =
            &e_2->u.ExpFor;
         _fx_R16Ast__for_flags_t* flags_0 = &vcase_25->t3;
         _fx_N10Ast__exp_t body_2 = vcase_25->t2;
         bool is_fold_0 = flags_0->for_flag_fold;
         bool is_nested_0 = flags_0->for_flag_nested;
         if (flags_0->for_flag_unzip) {
            fx_str_t slit_147 = FX_MAKE_STR("@unzip for does not make sense outside of comprehensions");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_147, &v_346, 0), _fx_catch_141);
            FX_THROW(&v_346, false, _fx_catch_141);
         }
         _fx_N12Ast__scope_t v_351;
         if (is_fold_0) {
            FX_CALL(_fx_M3AstFM14new_fold_scopeN12Ast__scope_t1i(curr_m_idx_0, &v_351, 0), _fx_catch_141);
         }
         else {
            FX_CALL(_fx_M3AstFM14new_loop_scopeN12Ast__scope_t2iB(curr_m_idx_0, is_nested_0, &v_351, 0), _fx_catch_141);
         }
         FX_CALL(_fx_cons_LN12Ast__scope_t(&v_351, sc_2, true, &for_sc_0), _fx_catch_141);
         FX_CALL(
            _fx_M13Ast_typecheckFM17check_for_clausesT7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t7LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tR16Ast__for_flags_tLN12Ast__scope_ti(
               vcase_25->t0, vcase_25->t1, &env_2, &_fx_g16Ast__empty_idset, flags_0, for_sc_0, curr_m_idx_0, &v_347, 0),
            _fx_catch_141);
         int_ trsz_0 = v_347.t0;
         FX_COPY_PTR(v_347.t1, &pre_code_0);
         FX_COPY_PTR(v_347.t2, &for_clauses_0);
         FX_COPY_PTR(v_347.t3, &idx_pat_0);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_347.t5, &env_4);
         if (trsz_0 > 0) {
            _fx_LN10Ast__exp_t lstend_7 = 0;
            for (int_ idx_2 = 0; idx_2 < trsz_0; idx_2++) {
               _fx_N10Ast__exp_t it_j_0 = 0;
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_352 = {0};
               _fx_N10Ast__typ_t tj_0 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM20gen_for_in_tuprec_itN10Ast__exp_t8iLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tLN12Ast__scope_t(
                     idx_2, for_clauses_0, idx_pat_0, body_2, &env_4, for_sc_0, &eloc_0, sc_2, &it_j_0, 0), _fx_catch_140);
               FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(it_j_0, &v_352, 0), _fx_catch_140);
               FX_COPY_PTR(v_352.t0, &tj_0);
               _fx_R10Ast__loc_t locj_0 = v_352.t1;
               fx_str_t slit_148 = FX_MAKE_STR("\'for()\' body should have \'void\' type");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(tj_0, _fx_g22Ast_typecheck__TypVoid,
                     &locj_0, &slit_148, 0), _fx_catch_140);
               _fx_LN10Ast__exp_t node_7 = 0;
               FX_CALL(_fx_cons_LN10Ast__exp_t(it_j_0, 0, false, &node_7), _fx_catch_140);
               FX_LIST_APPEND(code_0, lstend_7, node_7);

            _fx_catch_140: ;
               if (tj_0) {
                  _fx_free_N10Ast__typ_t(&tj_0);
               }
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_352);
               if (it_j_0) {
                  _fx_free_N10Ast__exp_t(&it_j_0);
               }
               FX_CHECK_EXN(_fx_catch_141);
            }
            FX_CALL(_fx_M13Ast_typecheckFM7__add__LN10Ast__exp_t2LN10Ast__exp_tLN10Ast__exp_t(pre_code_0, code_0, &v_348, 0),
               _fx_catch_141);
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g22Ast_typecheck__TypVoid, &eloc_0, &v_349);
            FX_CALL(_fx_M3AstFM6ExpSeqN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_348, &v_349, &result_41),
               _fx_catch_141);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_41, &result_0);
            FX_BREAK(_fx_catch_141);
         }
         else {
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(body_2, &v_350, 0), _fx_catch_141);
            FX_COPY_PTR(v_350.t0, &btyp_2);
            _fx_R10Ast__loc_t bloc_2 = v_350.t1;
            fx_str_t slit_149 = FX_MAKE_STR("\'for()\' body should have \'void\' type");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(btyp_2, _fx_g22Ast_typecheck__TypVoid,
                  &bloc_2, &slit_149, 0), _fx_catch_141);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  body_2, &env_4, for_sc_0, &new_body_2, 0), _fx_catch_141);
            FX_CALL(
               _fx_M3AstFM6ExpForN10Ast__exp_t5LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tRM11for_flags_tRM5loc_t(
                  for_clauses_0, idx_pat_0, new_body_2, flags_0, &eloc_0, &result_42), _fx_catch_141);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_42, &result_0);
            FX_BREAK(_fx_catch_141);
         }

      _fx_catch_141: ;
         if (result_42) {
            _fx_free_N10Ast__exp_t(&result_42);
         }
         if (new_body_2) {
            _fx_free_N10Ast__exp_t(&new_body_2);
         }
         if (btyp_2) {
            _fx_free_N10Ast__typ_t(&btyp_2);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_350);
         if (result_41) {
            _fx_free_N10Ast__exp_t(&result_41);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_349);
         if (v_348) {
            _fx_free_LN10Ast__exp_t(&v_348);
         }
         if (code_0) {
            _fx_free_LN10Ast__exp_t(&code_0);
         }
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_4);
         if (idx_pat_0) {
            _fx_free_N10Ast__pat_t(&idx_pat_0);
         }
         if (for_clauses_0) {
            _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&for_clauses_0);
         }
         if (pre_code_0) {
            _fx_free_LN10Ast__exp_t(&pre_code_0);
         }
         _fx_free_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
            &v_347);
         FX_FREE_LIST_SIMPLE(&for_sc_0);
         fx_free_exn(&v_346);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 27) {
         _fx_LN12Ast__scope_t for_sc_1 = 0;
         _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t
            __fold_result___3 = {0};
         _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t map_clauses_0 = 0;
         _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t
            v_353 = {0};
         _fx_LN10Ast__exp_t pre_code_1 = 0;
         _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t map_clauses_1 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_5 = {0};
         fx_exn_t v_354 = {0};
         fx_str_t coll_name_0 = {0};
         fx_exn_t v_355 = {0};
         _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t v_356 = {0};
         _fx_LT2N10Ast__pat_tN10Ast__exp_t for_clauses_1 = 0;
         _fx_N10Ast__pat_t idx_pat_1 = 0;
         _fx_N10Ast__typ_t elem_typ_0 = 0;
         _fx_LN10Ast__exp_t elems_0 = 0;
         _fx_N10Ast__exp_t mk_struct_exp_0 = 0;
         _fx_FPN10Ast__typ_t1N10Ast__exp_t get_exp_typ_0 = {0};
         _fx_LN10Ast__typ_t tl_1 = 0;
         _fx_N10Ast__typ_t v_357 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_358 = {0};
         _fx_N10Ast__typ_t ltyp_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_359 = {0};
         _fx_N10Ast__exp_t __fold_result___4 = 0;
         _fx_LN10Ast__exp_t v_360 = 0;
         _fx_N10Ast__typ_t v_361 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_362 = {0};
         _fx_LLN10Ast__exp_t v_363 = 0;
         _fx_N10Ast__typ_t v_364 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_365 = {0};
         _fx_N10Ast__typ_t coll_typ_0 = 0;
         fx_str_t v_366 = {0};
         fx_str_t v_367 = {0};
         _fx_LN10Ast__exp_t v_368 = 0;
         _fx_LN10Ast__exp_t v_369 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_370 = {0};
         _fx_N10Ast__exp_t result_43 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_371 = {0};
         _fx_N10Ast__typ_t btyp_3 = 0;
         _fx_N10Ast__exp_t new_body_3 = 0;
         _fx_N10Ast__typ_t v_372 = 0;
         _fx_N10Ast__typ_t v_373 = 0;
         _fx_Nt6option1N10Ast__typ_t v_374 = 0;
         _fx_N10Ast__typ_t v_375 = 0;
         _fx_N10Ast__typ_t v_376 = 0;
         _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t v_377 = 0;
         _fx_N10Ast__exp_t result_44 = 0;
         _fx_T4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tR16Ast__for_flags_tT2N10Ast__typ_tR10Ast__loc_t*
            vcase_26 = &e_2->u.ExpMap;
         _fx_R16Ast__for_flags_t* flags_1 = &vcase_26->t2;
         _fx_N10Ast__exp_t body_3 = vcase_26->t1;
         _fx_N15Ast__for_make_t v_378 = flags_1->for_flag_make;
         bool make_list_0 = v_378.tag == 3;
         _fx_N15Ast__for_make_t v_379 = flags_1->for_flag_make;
         bool make_tuple_0 = v_379.tag == 5;
         _fx_N15Ast__for_make_t v_380 = flags_1->for_flag_make;
         bool make_vector_0 = v_380.tag == 4;
         bool unzip_mode_0 = flags_1->for_flag_unzip;
         _fx_N12Ast__scope_t v_381;
         if (make_tuple_0) {
            FX_CALL(_fx_M3AstFM15new_block_scopeN12Ast__scope_t1i(curr_m_idx_0, &v_381, 0), _fx_catch_153);
         }
         else {
            bool t_10;
            if (make_list_0) {
               t_10 = true;
            }
            else {
               t_10 = make_vector_0;
            }
            if (t_10) {
               FX_CALL(_fx_M3AstFM13new_map_scopeN12Ast__scope_t1i(curr_m_idx_0, &v_381, 0), _fx_catch_153);
            }
            else {
               FX_CALL(_fx_M3AstFM17new_arr_map_scopeN12Ast__scope_t1i(curr_m_idx_0, &v_381, 0), _fx_catch_153);
            }
         }
         FX_CALL(_fx_cons_LN12Ast__scope_t(&v_381, sc_2, true, &for_sc_1), _fx_catch_153);
         _fx_make_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
            0, 0, 0, 0, &env_2, &_fx_g16Ast__empty_idset, &__fold_result___3);
         FX_COPY_PTR(vcase_26->t0, &map_clauses_0);
         _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t lst_10 = map_clauses_0;
         for (; lst_10; lst_10 = lst_10->tl) {
            _fx_LT2N10Ast__pat_tN10Ast__exp_t for_clauses_2 = 0;
            _fx_N10Ast__pat_t idx_pat_2 = 0;
            _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t
               v_382 = {0};
            _fx_LN10Ast__exp_t pre_code_2 = 0;
            _fx_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t map_clauses_2 = 0;
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_6 = {0};
            _fx_Rt6Set__t1R9Ast__id_t idset_0 = {0};
            _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t
               v_383 = {0};
            _fx_LN10Ast__exp_t pre_code_k_0 = 0;
            _fx_LT2N10Ast__pat_tN10Ast__exp_t for_clauses_3 = 0;
            _fx_N10Ast__pat_t idx_pat_3 = 0;
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_7 = {0};
            _fx_Rt6Set__t1R9Ast__id_t idset_1 = {0};
            _fx_LN10Ast__exp_t v_384 = 0;
            _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t v_385 = {0};
            _fx_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t
               v_386 = {0};
            _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t* __pat___2 = &lst_10->hd;
            FX_COPY_PTR(__pat___2->t0, &for_clauses_2);
            FX_COPY_PTR(__pat___2->t1, &idx_pat_2);
            _fx_copy_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
               &__fold_result___3, &v_382);
            FX_COPY_PTR(v_382.t1, &pre_code_2);
            FX_COPY_PTR(v_382.t2, &map_clauses_2);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_382.t4, &env_6);
            _fx_copy_Rt6Set__t1R9Ast__id_t(&v_382.t5, &idset_0);
            FX_CALL(
               _fx_M13Ast_typecheckFM17check_for_clausesT7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t7LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tR16Ast__for_flags_tLN12Ast__scope_ti(
                  for_clauses_2, idx_pat_2, &env_6, &idset_0, flags_1, for_sc_1, curr_m_idx_0, &v_383, 0), _fx_catch_142);
            int_ trsz_k_0 = v_383.t0;
            FX_COPY_PTR(v_383.t1, &pre_code_k_0);
            FX_COPY_PTR(v_383.t2, &for_clauses_3);
            FX_COPY_PTR(v_383.t3, &idx_pat_3);
            int_ dims_0 = v_383.t4;
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_383.t5, &env_7);
            _fx_copy_Rt6Set__t1R9Ast__id_t(&v_383.t6, &idset_1);
            FX_CALL(
               _fx_M13Ast_typecheckFM7__add__LN10Ast__exp_t2LN10Ast__exp_tLN10Ast__exp_t(pre_code_k_0, pre_code_2, &v_384, 0),
               _fx_catch_142);
            _fx_make_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(for_clauses_3, idx_pat_3, &v_385);
            FX_CALL(_fx_cons_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&v_385, map_clauses_2, false, &map_clauses_2),
               _fx_catch_142);
            _fx_make_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
               v_382.t0 + trsz_k_0, v_384, map_clauses_2, v_382.t3 + dims_0, &env_7, &idset_1, &v_386);
            _fx_free_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
               &__fold_result___3);
            _fx_copy_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
               &v_386, &__fold_result___3);

         _fx_catch_142: ;
            _fx_free_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
               &v_386);
            _fx_free_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&v_385);
            if (v_384) {
               _fx_free_LN10Ast__exp_t(&v_384);
            }
            _fx_free_Rt6Set__t1R9Ast__id_t(&idset_1);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_7);
            if (idx_pat_3) {
               _fx_free_N10Ast__pat_t(&idx_pat_3);
            }
            if (for_clauses_3) {
               _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&for_clauses_3);
            }
            if (pre_code_k_0) {
               _fx_free_LN10Ast__exp_t(&pre_code_k_0);
            }
            _fx_free_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
               &v_383);
            _fx_free_Rt6Set__t1R9Ast__id_t(&idset_0);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_6);
            if (map_clauses_2) {
               _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&map_clauses_2);
            }
            if (pre_code_2) {
               _fx_free_LN10Ast__exp_t(&pre_code_2);
            }
            _fx_free_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
               &v_382);
            if (idx_pat_2) {
               _fx_free_N10Ast__pat_t(&idx_pat_2);
            }
            if (for_clauses_2) {
               _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&for_clauses_2);
            }
            FX_CHECK_EXN(_fx_catch_153);
         }
         _fx_copy_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
            &__fold_result___3, &v_353);
         int_ trsz_1 = v_353.t0;
         FX_COPY_PTR(v_353.t1, &pre_code_1);
         FX_COPY_PTR(v_353.t2, &map_clauses_1);
         int_ total_dims_0 = v_353.t3;
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_353.t4, &env_5);
         bool t_11;
         if (make_tuple_0) {
            t_11 = trsz_1 == 0;
         }
         else {
            t_11 = false;
         }
         if (t_11) {
            fx_str_t slit_150 =
               FX_MAKE_STR("tuple comprehension with iteration over non-tuples and non-records is not supported");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_150, &v_354, 0), _fx_catch_153);
            FX_THROW(&v_354, false, _fx_catch_153);
         }
         if (make_list_0) {
            fx_str_t slit_151 = FX_MAKE_STR("list"); fx_copy_str(&slit_151, &coll_name_0);
         }
         else if (make_tuple_0) {
            fx_str_t slit_152 = FX_MAKE_STR("tuple"); fx_copy_str(&slit_152, &coll_name_0);
         }
         else if (make_vector_0) {
            fx_str_t slit_153 = FX_MAKE_STR("vector"); fx_copy_str(&slit_153, &coll_name_0);
         }
         else {
            fx_str_t slit_154 = FX_MAKE_STR("array"); fx_copy_str(&slit_154, &coll_name_0);
         }
         if (trsz_1 > 0) {
            if (flags_1->for_flag_unzip) {
               fx_str_t slit_155 = FX_MAKE_STR("@unzip for is not supported in tuple/record comprehensions");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_155, &v_355, 0), _fx_catch_153);
               FX_THROW(&v_355, false, _fx_catch_153);
            }
            if (map_clauses_1 != 0) {
               if (map_clauses_1->tl == 0) {
                  _fx_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t* v_387 = &map_clauses_1->hd;
                  _fx_make_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(v_387->t0, v_387->t1, &v_356);
                  goto _fx_endmatch_30;
               }
            }
            fx_exn_t v_388 = {0};
            fx_str_t slit_156 = FX_MAKE_STR("tuple comprehension with nested for is not supported yet");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_156, &v_388, 0), _fx_catch_143);
            FX_THROW(&v_388, false, _fx_catch_143);

         _fx_catch_143: ;
            fx_free_exn(&v_388);

         _fx_endmatch_30: ;
            FX_CHECK_EXN(_fx_catch_153);
            FX_COPY_PTR(v_356.t0, &for_clauses_1);
            FX_COPY_PTR(v_356.t1, &idx_pat_1);
            FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&elem_typ_0, 0), _fx_catch_153);
            _fx_LN10Ast__exp_t lstend_8 = 0;
            for (int_ idx_3 = 0; idx_3 < trsz_1; idx_3++) {
               _fx_N10Ast__exp_t it_j_1 = 0;
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_389 = {0};
               _fx_N10Ast__typ_t tj_1 = 0;
               fx_str_t v_390 = {0};
               fx_str_t v_391 = {0};
               FX_CALL(
                  _fx_M13Ast_typecheckFM20gen_for_in_tuprec_itN10Ast__exp_t8iLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tLN12Ast__scope_t(
                     idx_3, for_clauses_1, idx_pat_1, body_3, &env_5, for_sc_1, &eloc_0, sc_2, &it_j_1, 0), _fx_catch_144);
               FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(it_j_1, &v_389, 0), _fx_catch_144);
               FX_COPY_PTR(v_389.t0, &tj_1);
               _fx_R10Ast__loc_t locj_1 = v_389.t1;
               if (!make_tuple_0) {
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&coll_name_0, &v_390, 0), _fx_catch_144);
                  fx_str_t slit_157 = FX_MAKE_STR(" comprehension should produce elements of the same type");
                  {
                     const fx_str_t strs_16[] = { v_390, slit_157 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_16, 2, &v_391), _fx_catch_144);
                  }
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(tj_1, elem_typ_0, &locj_1, &v_391,
                        0), _fx_catch_144);
               }
               _fx_LN10Ast__exp_t node_8 = 0;
               FX_CALL(_fx_cons_LN10Ast__exp_t(it_j_1, 0, false, &node_8), _fx_catch_144);
               FX_LIST_APPEND(elems_0, lstend_8, node_8);

            _fx_catch_144: ;
               FX_FREE_STR(&v_391);
               FX_FREE_STR(&v_390);
               if (tj_1) {
                  _fx_free_N10Ast__typ_t(&tj_1);
               }
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_389);
               if (it_j_1) {
                  _fx_free_N10Ast__exp_t(&it_j_1);
               }
               FX_CHECK_EXN(_fx_catch_153);
            }
            if (make_tuple_0) {
               _fx_FPN10Ast__typ_t1N10Ast__exp_t get_exp_typ_fp_0 = { _fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t, 0 };
               FX_COPY_FP(&get_exp_typ_fp_0, &get_exp_typ_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM3mapLN10Ast__typ_t2LN10Ast__exp_tFPN10Ast__typ_t1N10Ast__exp_t(elems_0, &get_exp_typ_0,
                     &tl_1, 0), _fx_catch_153);
               FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(tl_1, &v_357), _fx_catch_153);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_357, &eloc_0, &v_358);
               FX_CALL(
                  _fx_M3AstFM10ExpMkTupleN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(elems_0, &v_358, &mk_struct_exp_0),
                  _fx_catch_153);
            }
            else if (make_list_0) {
               FX_CALL(_fx_M3AstFM7TypListN10Ast__typ_t1N10Ast__typ_t(elem_typ_0, &ltyp_0), _fx_catch_153);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(ltyp_0, &eloc_0, &v_359);
               FX_CALL(
                  _fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&_fx_g23Ast_typecheck__LitEmpty, &v_359,
                     &__fold_result___4), _fx_catch_153);
               FX_CALL(_fx_M13Ast_typecheckFM3revLN10Ast__exp_t1LN10Ast__exp_t(elems_0, &v_360, 0), _fx_catch_153);
               _fx_LN10Ast__exp_t lst_11 = v_360;
               for (; lst_11; lst_11 = lst_11->tl) {
                  _fx_N10Ast__exp_t l_exp_0 = 0;
                  _fx_T2N10Ast__typ_tR10Ast__loc_t v_392 = {0};
                  _fx_N10Ast__exp_t v_393 = 0;
                  _fx_N10Ast__exp_t ej_0 = lst_11->hd;
                  FX_COPY_PTR(__fold_result___4, &l_exp_0);
                  _fx_make_T2N10Ast__typ_tR10Ast__loc_t(ltyp_0, &eloc_0, &v_392);
                  FX_CALL(
                     _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                        _fx_g21Ast_typecheck__OpCons, ej_0, l_exp_0, &v_392, &v_393), _fx_catch_145);
                  _fx_free_N10Ast__exp_t(&__fold_result___4);
                  FX_COPY_PTR(v_393, &__fold_result___4);

               _fx_catch_145: ;
                  if (v_393) {
                     _fx_free_N10Ast__exp_t(&v_393);
                  }
                  _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_392);
                  if (l_exp_0) {
                     _fx_free_N10Ast__exp_t(&l_exp_0);
                  }
                  FX_CHECK_EXN(_fx_catch_153);
               }
               FX_COPY_PTR(__fold_result___4, &mk_struct_exp_0);
            }
            else if (make_vector_0) {
               FX_CALL(_fx_M3AstFM9TypVectorN10Ast__typ_t1N10Ast__typ_t(elem_typ_0, &v_361), _fx_catch_153);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_361, &eloc_0, &v_362);
               FX_CALL(
                  _fx_M3AstFM11ExpMkVectorN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(elems_0, &v_362,
                     &mk_struct_exp_0), _fx_catch_153);
            }
            else {
               FX_CALL(_fx_cons_LLN10Ast__exp_t(elems_0, 0, true, &v_363), _fx_catch_153);
               FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(1, elem_typ_0, &v_364), _fx_catch_153);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_364, &eloc_0, &v_365);
               FX_CALL(
                  _fx_M3AstFM10ExpMkArrayN10Ast__exp_t2LLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_363, &v_365, &mk_struct_exp_0),
                  _fx_catch_153);
            }
            FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(mk_struct_exp_0, &coll_typ_0, 0), _fx_catch_153);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&coll_name_0, &v_366, 0), _fx_catch_153);
            fx_str_t slit_158 = FX_MAKE_STR("inconsistent type of the constructed ");
            {
               const fx_str_t strs_17[] = { slit_158, v_366 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_17, 2, &v_367), _fx_catch_153);
            }
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, coll_typ_0, &eloc_0, &v_367, 0),
               _fx_catch_153);
            FX_CALL(_fx_cons_LN10Ast__exp_t(mk_struct_exp_0, 0, true, &v_368), _fx_catch_153);
            FX_CALL(_fx_M13Ast_typecheckFM7__add__LN10Ast__exp_t2LN10Ast__exp_tLN10Ast__exp_t(pre_code_1, v_368, &v_369, 0),
               _fx_catch_153);
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(coll_typ_0, &eloc_0, &v_370);
            FX_CALL(_fx_M3AstFM6ExpSeqN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_369, &v_370, &result_43),
               _fx_catch_153);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_43, &result_0);
            FX_BREAK(_fx_catch_153);
         }
         else {
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(body_3, &v_371, 0), _fx_catch_153);
            FX_COPY_PTR(v_371.t0, &btyp_3);
            if (!unzip_mode_0) {
               FX_CALL(
                  _fx_M13Ast_typecheckFM13check_map_typv7N10Ast__typ_tN10Ast__typ_tiR10Ast__loc_tBBi(btyp_3, etyp_0, -1,
                     &eloc_0, make_list_0, make_vector_0, total_dims_0, 0), _fx_catch_153);
            }
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  body_3, &env_5, for_sc_1, &new_body_3, 0), _fx_catch_153);
            bool new_unzip_mode_0;
            if (unzip_mode_0) {
               FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(btyp_3, &v_372, 0), _fx_catch_153);
               FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp_0, &v_373, 0), _fx_catch_153);
               if (FX_REC_VARIANT_TAG(v_373) == 1) {
                  FX_COPY_PTR(v_373->u.TypVar->data, &v_374);
                  if ((v_374 != 0) + 1 == 1) {
                     if (FX_REC_VARIANT_TAG(v_372) == 17) {
                        _fx_LN10Ast__typ_t colls_0 = 0;
                        _fx_LN10Ast__typ_t b_elems_0 = 0;
                        _fx_N10Ast__typ_t v_394 = 0;
                        _fx_LN10Ast__typ_t lstend_9 = 0;
                        int_ i_0 = 0;
                        FX_COPY_PTR(v_372->u.TypTuple, &b_elems_0);
                        _fx_LN10Ast__typ_t lst_12 = b_elems_0;
                        for (; lst_12; lst_12 = lst_12->tl, i_0 += 1) {
                           _fx_N10Ast__typ_t ct_0 = 0;
                           _fx_N10Ast__typ_t bt_0 = lst_12->hd;
                           FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&ct_0, 0), _fx_catch_146);
                           FX_CALL(
                              _fx_M13Ast_typecheckFM13check_map_typv7N10Ast__typ_tN10Ast__typ_tiR10Ast__loc_tBBi(bt_0, ct_0,
                                 i_0, &eloc_0, make_list_0, make_vector_0, total_dims_0, 0), _fx_catch_146);
                           _fx_LN10Ast__typ_t node_9 = 0;
                           FX_CALL(_fx_cons_LN10Ast__typ_t(ct_0, 0, false, &node_9), _fx_catch_146);
                           FX_LIST_APPEND(colls_0, lstend_9, node_9);

                        _fx_catch_146: ;
                           if (ct_0) {
                              _fx_free_N10Ast__typ_t(&ct_0);
                           }
                           FX_CHECK_EXN(_fx_catch_147);
                        }
                        FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(colls_0, &v_394), _fx_catch_147);
                        fx_str_t slit_159 = FX_MAKE_STR("incorrect type of @unzip\'ped comprehension");
                        FX_CALL(
                           _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, v_394, &eloc_0,
                              &slit_159, 0), _fx_catch_147);
                        new_unzip_mode_0 = true;

                     _fx_catch_147: ;
                        if (v_394) {
                           _fx_free_N10Ast__typ_t(&v_394);
                        }
                        if (b_elems_0) {
                           _fx_free_LN10Ast__typ_t(&b_elems_0);
                        }
                        if (colls_0) {
                           _fx_free_LN10Ast__typ_t(&colls_0);
                        }
                        goto _fx_endmatch_31;
                     }
                  }
               }
               if (FX_REC_VARIANT_TAG(v_373) == 17) {
                  if (FX_REC_VARIANT_TAG(v_372) == 17) {
                     fx_str_t v_395 = {0};
                     fx_str_t v_396 = {0};
                     fx_str_t v_397 = {0};
                     fx_exn_t v_398 = {0};
                     _fx_LN10Ast__typ_t b_elems_1 = 0;
                     _fx_LN10Ast__typ_t colls_1 = 0;
                     _fx_LN10Ast__typ_t b_elems_2 = v_372->u.TypTuple;
                     _fx_LN10Ast__typ_t colls_2 = v_373->u.TypTuple;
                     int_ nb_elems_0;
                     FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(b_elems_2, &nb_elems_0, 0), _fx_catch_149);
                     int_ ncolls_0;
                     FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(colls_2, &ncolls_0, 0), _fx_catch_149);
                     if (nb_elems_0 != ncolls_0) {
                        FX_CALL(_fx_F6stringS1i(nb_elems_0, &v_395, 0), _fx_catch_149);
                        FX_CALL(_fx_F6stringS1i(ncolls_0, &v_396, 0), _fx_catch_149);
                        fx_str_t slit_160 =
                           FX_MAKE_STR("the number of elements in a tuple produced by the @unzip\'pped comprehension (=");
                        fx_str_t slit_161 = FX_MAKE_STR(") and in the output tuple (=");
                        fx_str_t slit_162 = FX_MAKE_STR(") do not match");
                        {
                           const fx_str_t strs_18[] = { slit_160, v_395, slit_161, v_396, slit_162 };
                           FX_CALL(fx_strjoin(0, 0, 0, strs_18, 5, &v_397), _fx_catch_149);
                        }
                        FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_397, &v_398, 0), _fx_catch_149);
                        FX_THROW(&v_398, false, _fx_catch_149);
                     }
                     int_ i_1 = 0;
                     FX_COPY_PTR(b_elems_2, &b_elems_1);
                     _fx_LN10Ast__typ_t lst_13 = b_elems_1;
                     FX_COPY_PTR(colls_2, &colls_1);
                     _fx_LN10Ast__typ_t lst_14 = colls_1;
                     for (; lst_13 && lst_14; lst_14 = lst_14->tl, lst_13 = lst_13->tl, i_1 += 1) {
                        _fx_N10Ast__typ_t ct_1 = lst_14->hd;
                        _fx_N10Ast__typ_t bt_1 = lst_13->hd;
                        FX_CALL(
                           _fx_M13Ast_typecheckFM13check_map_typv7N10Ast__typ_tN10Ast__typ_tiR10Ast__loc_tBBi(bt_1, ct_1, i_1,
                              &eloc_0, make_list_0, make_vector_0, total_dims_0, 0), _fx_catch_148);

                     _fx_catch_148: ;
                        FX_CHECK_EXN(_fx_catch_149);
                     }
                     int s_0 = !lst_13 + !lst_14;
                     FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_149);
                     new_unzip_mode_0 = true;

                  _fx_catch_149: ;
                     if (colls_1) {
                        _fx_free_LN10Ast__typ_t(&colls_1);
                     }
                     if (b_elems_1) {
                        _fx_free_LN10Ast__typ_t(&b_elems_1);
                     }
                     fx_free_exn(&v_398);
                     FX_FREE_STR(&v_397);
                     FX_FREE_STR(&v_396);
                     FX_FREE_STR(&v_395);
                     goto _fx_endmatch_31;
                  }
               }
               bool res_36;
               if (FX_REC_VARIANT_TAG(v_372) == 17) {
                  res_36 = true;
               }
               else if (FX_REC_VARIANT_TAG(v_373) == 17) {
                  res_36 = true;
               }
               else {
                  res_36 = false;
               }
               FX_CHECK_EXN(_fx_catch_153);
               if (res_36) {
                  fx_str_t v_399 = {0};
                  fx_str_t v_400 = {0};
                  fx_str_t v_401 = {0};
                  fx_str_t v_402 = {0};
                  fx_str_t v_403 = {0};
                  fx_exn_t v_404 = {0};
                  FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(btyp_3, &v_399, 0), _fx_catch_150);
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_399, &v_400, 0), _fx_catch_150);
                  FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp_0, &v_401, 0), _fx_catch_150);
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_401, &v_402, 0), _fx_catch_150);
                  fx_str_t slit_163 = FX_MAKE_STR("in the case of @unzip comprehension either both the body type \'");
                  fx_str_t slit_164 = FX_MAKE_STR("\' and the result type (\'");
                  fx_str_t slit_165 = FX_MAKE_STR("\') should be tuples or none of them");
                  {
                     const fx_str_t strs_19[] = { slit_163, v_400, slit_164, v_402, slit_165 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_19, 5, &v_403), _fx_catch_150);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_403, &v_404, 0), _fx_catch_150);
                  FX_THROW(&v_404, false, _fx_catch_150);

               _fx_catch_150: ;
                  fx_free_exn(&v_404);
                  FX_FREE_STR(&v_403);
                  FX_FREE_STR(&v_402);
                  FX_FREE_STR(&v_401);
                  FX_FREE_STR(&v_400);
                  FX_FREE_STR(&v_399);
                  goto _fx_endmatch_31;
               }
               FX_CALL(
                  _fx_M13Ast_typecheckFM13check_map_typv7N10Ast__typ_tN10Ast__typ_tiR10Ast__loc_tBBi(btyp_3, etyp_0, -1,
                     &eloc_0, make_list_0, make_vector_0, total_dims_0, 0), _fx_catch_151);
               new_unzip_mode_0 = false;

            _fx_catch_151: ;

            _fx_endmatch_31: ;
               FX_CHECK_EXN(_fx_catch_153);
            }
            else {
               FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(new_body_3, &v_375, 0), _fx_catch_153);
               FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(v_375, &v_376, 0), _fx_catch_153);
               if (FX_REC_VARIANT_TAG(v_376) == 13) {
                  fx_exn_t v_405 = {0};
                  fx_str_t slit_166 = FX_MAKE_STR("comprehension body cannot have \'void\' type");
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_166, &v_405, 0), _fx_catch_152);
                  FX_THROW(&v_405, false, _fx_catch_152);

               _fx_catch_152: ;
                  fx_free_exn(&v_405);
               }
               else {
                  new_unzip_mode_0 = false;
               }
               FX_CHECK_EXN(_fx_catch_153);
            }
            FX_CALL(
               _fx_M13Ast_typecheckFM3revLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t1LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(
                  map_clauses_1, &v_377, 0), _fx_catch_153);
            _fx_R16Ast__for_flags_t v_406 =
               { flags_1->for_flag_parallel, flags_1->for_flag_make, new_unzip_mode_0, flags_1->for_flag_fold,
                  flags_1->for_flag_nested };
            FX_CALL(
               _fx_M3AstFM6ExpMapN10Ast__exp_t4LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tRM11for_flags_tT2N10Ast__typ_tRM5loc_t(
                  v_377, new_body_3, &v_406, &vcase_26->t3, &result_44), _fx_catch_153);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_44, &result_0);
            FX_BREAK(_fx_catch_153);
         }

      _fx_catch_153: ;
         if (result_44) {
            _fx_free_N10Ast__exp_t(&result_44);
         }
         if (v_377) {
            _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&v_377);
         }
         if (v_376) {
            _fx_free_N10Ast__typ_t(&v_376);
         }
         if (v_375) {
            _fx_free_N10Ast__typ_t(&v_375);
         }
         if (v_374) {
            _fx_free_Nt6option1N10Ast__typ_t(&v_374);
         }
         if (v_373) {
            _fx_free_N10Ast__typ_t(&v_373);
         }
         if (v_372) {
            _fx_free_N10Ast__typ_t(&v_372);
         }
         if (new_body_3) {
            _fx_free_N10Ast__exp_t(&new_body_3);
         }
         if (btyp_3) {
            _fx_free_N10Ast__typ_t(&btyp_3);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_371);
         if (result_43) {
            _fx_free_N10Ast__exp_t(&result_43);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_370);
         if (v_369) {
            _fx_free_LN10Ast__exp_t(&v_369);
         }
         if (v_368) {
            _fx_free_LN10Ast__exp_t(&v_368);
         }
         FX_FREE_STR(&v_367);
         FX_FREE_STR(&v_366);
         if (coll_typ_0) {
            _fx_free_N10Ast__typ_t(&coll_typ_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_365);
         if (v_364) {
            _fx_free_N10Ast__typ_t(&v_364);
         }
         if (v_363) {
            _fx_free_LLN10Ast__exp_t(&v_363);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_362);
         if (v_361) {
            _fx_free_N10Ast__typ_t(&v_361);
         }
         if (v_360) {
            _fx_free_LN10Ast__exp_t(&v_360);
         }
         if (__fold_result___4) {
            _fx_free_N10Ast__exp_t(&__fold_result___4);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_359);
         if (ltyp_0) {
            _fx_free_N10Ast__typ_t(&ltyp_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_358);
         if (v_357) {
            _fx_free_N10Ast__typ_t(&v_357);
         }
         if (tl_1) {
            _fx_free_LN10Ast__typ_t(&tl_1);
         }
         FX_FREE_FP(&get_exp_typ_0);
         if (mk_struct_exp_0) {
            _fx_free_N10Ast__exp_t(&mk_struct_exp_0);
         }
         if (elems_0) {
            _fx_free_LN10Ast__exp_t(&elems_0);
         }
         if (elem_typ_0) {
            _fx_free_N10Ast__typ_t(&elem_typ_0);
         }
         if (idx_pat_1) {
            _fx_free_N10Ast__pat_t(&idx_pat_1);
         }
         if (for_clauses_1) {
            _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&for_clauses_1);
         }
         _fx_free_T2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&v_356);
         fx_free_exn(&v_355);
         FX_FREE_STR(&coll_name_0);
         fx_free_exn(&v_354);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_5);
         if (map_clauses_1) {
            _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&map_clauses_1);
         }
         if (pre_code_1) {
            _fx_free_LN10Ast__exp_t(&pre_code_1);
         }
         _fx_free_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
            &v_353);
         if (map_clauses_0) {
            _fx_free_LT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_t(&map_clauses_0);
         }
         _fx_free_T6iLN10Ast__exp_tLT2LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
            &__fold_result___3);
         FX_FREE_LIST_SIMPLE(&for_sc_1);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 2) {
         FX_CALL(
            _fx_M13Ast_typecheckFM16check_inside_forv5BBBLN12Ast__scope_tR10Ast__loc_t(e_2->u.ExpBreak.t0, true, false, sc_2,
               &eloc_0, 0), _fx_catch_154);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(e_2, &result_0);
         FX_BREAK(_fx_catch_154);

      _fx_catch_154: ;
         goto _fx_endmatch_41;
      }
      if (tag_0 == 3) {
         FX_CALL(
            _fx_M13Ast_typecheckFM16check_inside_forv5BBBLN12Ast__scope_tR10Ast__loc_t(false, false, false, sc_2, &eloc_0, 0),
            _fx_catch_155);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(e_2, &result_0);
         FX_BREAK(_fx_catch_155);

      _fx_catch_155: ;
         goto _fx_endmatch_41;
      }
      if (tag_0 == 4) {
         _fx_N10Ast__typ_t t_12 = 0;
         _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t all_func_ctx_0 = 0;
         _fx_Nt6option1N10Ast__exp_t v_407 = 0;
         _fx_N10Ast__exp_t result_45 = 0;
         _fx_Nt6option1N10Ast__exp_t e_opt_0 = e_2->u.ExpReturn.t0;
         fx_str_t slit_167 = FX_MAKE_STR("return statement should have \'void\' type");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, _fx_g22Ast_typecheck__TypVoid,
               &eloc_0, &slit_167, 0), _fx_catch_160);
         if ((e_opt_0 != 0) + 1 == 2) {
            FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(e_opt_0->u.Some, &t_12, 0), _fx_catch_156);

         _fx_catch_156: ;
         }
         else {
            FX_COPY_PTR(_fx_g22Ast_typecheck__TypVoid, &t_12);
         }
         FX_CHECK_EXN(_fx_catch_160);
         FX_COPY_PTR(_fx_g17Ast__all_func_ctx, &all_func_ctx_0);
         if (all_func_ctx_0 != 0) {
            fx_str_t v_408 = {0};
            fx_str_t v_409 = {0};
            fx_str_t v_410 = {0};
            fx_str_t v_411 = {0};
            fx_str_t v_412 = {0};
            fx_str_t v_413 = {0};
            fx_str_t v_414 = {0};
            _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t* v_415 = &all_func_ctx_0->hd;
            _fx_N10Ast__typ_t rt_0 = v_415->t1;
            FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t_12, &v_408, 0), _fx_catch_157);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_408, &v_409, 0), _fx_catch_157);
            FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(rt_0, &v_410, 0), _fx_catch_157);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_410, &v_411, 0), _fx_catch_157);
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_415->t0, &v_412, 0), _fx_catch_157);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_412, &v_413, 0), _fx_catch_157);
            fx_str_t slit_168 = FX_MAKE_STR("the return statement type ");
            fx_str_t slit_169 = FX_MAKE_STR(" is inconsistent with the previously deduced type ");
            fx_str_t slit_170 = FX_MAKE_STR(" of function ");
            {
               const fx_str_t strs_20[] = { slit_168, v_409, slit_169, v_411, slit_170, v_413 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_20, 6, &v_414), _fx_catch_157);
            }
            FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t_12, rt_0, &eloc_0, &v_414, 0),
               _fx_catch_157);

         _fx_catch_157: ;
            FX_FREE_STR(&v_414);
            FX_FREE_STR(&v_413);
            FX_FREE_STR(&v_412);
            FX_FREE_STR(&v_411);
            FX_FREE_STR(&v_410);
            FX_FREE_STR(&v_409);
            FX_FREE_STR(&v_408);
         }
         else {
            fx_exn_t v_416 = {0};
            fx_str_t slit_171 = FX_MAKE_STR("return statement occurs outside of a function body");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_171, &v_416, 0), _fx_catch_158);
            FX_THROW(&v_416, false, _fx_catch_158);

         _fx_catch_158: ;
            fx_free_exn(&v_416);
         }
         FX_CHECK_EXN(_fx_catch_160);
         if ((e_opt_0 != 0) + 1 == 2) {
            _fx_N10Ast__exp_t v_417 = 0;
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  e_opt_0->u.Some, &env_2, sc_2, &v_417, 0), _fx_catch_159);
            FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(v_417, &v_407), _fx_catch_159);

         _fx_catch_159: ;
            if (v_417) {
               _fx_free_N10Ast__exp_t(&v_417);
            }
         }
         else {
            FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, &v_407);
         }
         FX_CHECK_EXN(_fx_catch_160);
         FX_CALL(_fx_M3AstFM9ExpReturnN10Ast__exp_t2Nt6option1N10Ast__exp_tRM5loc_t(v_407, &eloc_0, &result_45), _fx_catch_160);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_45, &result_0);
         FX_BREAK(_fx_catch_160);

      _fx_catch_160: ;
         if (result_45) {
            _fx_free_N10Ast__exp_t(&result_45);
         }
         if (v_407) {
            _fx_free_Nt6option1N10Ast__exp_t(&v_407);
         }
         if (all_func_ctx_0) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&all_func_ctx_0);
         }
         if (t_12) {
            _fx_free_N10Ast__typ_t(&t_12);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 14) {
         _fx_N10Ast__typ_t elemtyp_1 = 0;
         _fx_T4iLLN10Ast__exp_tBi __fold_result___5 = {0};
         _fx_LLN10Ast__exp_t arows_0 = 0;
         _fx_T4iLLN10Ast__exp_tBi v_418 = {0};
         _fx_LLN10Ast__exp_t arows_1 = 0;
         _fx_N10Ast__typ_t atyp_0 = 0;
         _fx_LLN10Ast__exp_t v_419 = 0;
         _fx_N10Ast__exp_t result_46 = 0;
         FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&elemtyp_1, 0), _fx_catch_169);
         _fx_make_T4iLLN10Ast__exp_tBi(0, 0, false, -1, &__fold_result___5);
         int_ k_0 = 0;
         FX_COPY_PTR(e_2->u.ExpMkArray.t0, &arows_0);
         _fx_LLN10Ast__exp_t lst_15 = arows_0;
         for (; lst_15; lst_15 = lst_15->tl, k_0 += 1) {
            _fx_T4iLLN10Ast__exp_tBi v_420 = {0};
            _fx_LLN10Ast__exp_t arows_2 = 0;
            _fx_T3BiLN10Ast__exp_t __fold_result___6 = {0};
            _fx_T3BiLN10Ast__exp_t v_421 = {0};
            _fx_LN10Ast__exp_t arow_0 = 0;
            fx_str_t v_422 = {0};
            fx_str_t v_423 = {0};
            fx_str_t v_424 = {0};
            fx_str_t v_425 = {0};
            fx_exn_t v_426 = {0};
            fx_str_t v_427 = {0};
            fx_str_t v_428 = {0};
            fx_str_t v_429 = {0};
            fx_str_t v_430 = {0};
            fx_exn_t v_431 = {0};
            _fx_LN10Ast__exp_t v_432 = 0;
            _fx_LLN10Ast__exp_t v_433 = 0;
            _fx_T4iLLN10Ast__exp_tBi v_434 = {0};
            _fx_LN10Ast__exp_t arow_1 = lst_15->hd;
            _fx_copy_T4iLLN10Ast__exp_tBi(&__fold_result___5, &v_420);
            int_ ncols_0 = v_420.t0;
            FX_COPY_PTR(v_420.t1, &arows_2);
            _fx_make_T3BiLN10Ast__exp_t(false, -1, 0, &__fold_result___6);
            _fx_LN10Ast__exp_t lst_16 = arow_1;
            for (; lst_16; lst_16 = lst_16->tl) {
               _fx_T3BiLN10Ast__exp_t v_435 = {0};
               _fx_LN10Ast__exp_t arow_2 = 0;
               _fx_T4BiN10Ast__exp_tR10Ast__loc_t v_436 = {0};
               _fx_N10Ast__exp_t elem1_0 = 0;
               fx_str_t v_437 = {0};
               fx_str_t v_438 = {0};
               fx_str_t v_439 = {0};
               fx_exn_t v_440 = {0};
               _fx_T3BiLN10Ast__exp_t v_441 = {0};
               _fx_N10Ast__exp_t elem_0 = lst_16->hd;
               _fx_copy_T3BiLN10Ast__exp_t(&__fold_result___6, &v_435);
               int_ row_dims_0 = v_435.t1;
               FX_COPY_PTR(v_435.t2, &arow_2);
               if (FX_REC_VARIANT_TAG(elem_0) == 9) {
                  _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_27 = &elem_0->u.ExpUnary;
                  if (vcase_27->t0.tag == 8) {
                     _fx_N10Ast__exp_t e1_5 = 0;
                     _fx_T2N10Ast__typ_tR10Ast__loc_t v_442 = {0};
                     _fx_N10Ast__typ_t arrtyp1_0 = 0;
                     _fx_N10Ast__typ_t v_443 = 0;
                     _fx_T3SiN10Ast__typ_t v_444 = {0};
                     fx_str_t collname_0 = {0};
                     _fx_N10Ast__typ_t elemtyp1_0 = 0;
                     fx_exn_t v_445 = {0};
                     fx_str_t v_446 = {0};
                     fx_str_t v_447 = {0};
                     _fx_T2N10Ast__typ_tR10Ast__loc_t v_448 = {0};
                     _fx_N10Ast__exp_t v_449 = 0;
                     _fx_T2N10Ast__typ_tR10Ast__loc_t* v_450 = &vcase_27->t2;
                     _fx_R10Ast__loc_t* loc_0 = &v_450->t1;
                     FX_CALL(
                        _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                           vcase_27->t1, &env_2, sc_2, &e1_5, 0), _fx_catch_162);
                     FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_5, &v_442, 0), _fx_catch_162);
                     FX_COPY_PTR(v_442.t0, &arrtyp1_0);
                     _fx_R10Ast__loc_t eloc1_8 = v_442.t1;
                     fx_str_t slit_172 = FX_MAKE_STR("incorrect type of expanded collection");
                     FX_CALL(
                        _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(v_450->t0, arrtyp1_0, loc_0,
                           &slit_172, 0), _fx_catch_162);
                     FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(arrtyp1_0, &v_443, 0), _fx_catch_162);
                     int tag_12 = FX_REC_VARIANT_TAG(v_443);
                     if (tag_12 == 19) {
                        _fx_T2iN10Ast__typ_t* vcase_28 = &v_443->u.TypArray;
                        fx_str_t slit_173 = FX_MAKE_STR("array");
                        _fx_make_T3SiN10Ast__typ_t(&slit_173, vcase_28->t0, vcase_28->t1, &v_444);
                     }
                     else if (tag_12 == 15) {
                        fx_str_t slit_174 = FX_MAKE_STR("list");
                        _fx_make_T3SiN10Ast__typ_t(&slit_174, 1, v_443->u.TypList, &v_444);
                     }
                     else if (tag_12 == 10) {
                        fx_str_t slit_175 = FX_MAKE_STR("string");
                        _fx_make_T3SiN10Ast__typ_t(&slit_175, 1, _fx_g22Ast_typecheck__TypChar, &v_444);
                     }
                     else {
                        fx_exn_t v_451 = {0};
                        fx_str_t slit_176 =
                           FX_MAKE_STR("incorrect type of expanded collection (it should be an array, list or string)");
                        FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_176, &v_451, 0), _fx_catch_161);
                        FX_THROW(&v_451, false, _fx_catch_161);

                     _fx_catch_161: ;
                        fx_free_exn(&v_451);
                     }
                     FX_CHECK_EXN(_fx_catch_162);
                     fx_copy_str(&v_444.t0, &collname_0);
                     int_ d_0 = v_444.t1;
                     FX_COPY_PTR(v_444.t2, &elemtyp1_0);
                     if (d_0 > 2) {
                        fx_str_t slit_177 =
                           FX_MAKE_STR("currently expansion of more than 2-dimensional arrays is not supported");
                        FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_177, &v_445, 0), _fx_catch_162);
                        FX_THROW(&v_445, false, _fx_catch_162);
                     }
                     FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&collname_0, &v_446, 0), _fx_catch_162);
                     fx_str_t slit_178 = FX_MAKE_STR("the expanded ");
                     fx_str_t slit_179 = FX_MAKE_STR(" elem type does not match the previous elements");
                     {
                        const fx_str_t strs_21[] = { slit_178, v_446, slit_179 };
                        FX_CALL(fx_strjoin(0, 0, 0, strs_21, 3, &v_447), _fx_catch_162);
                     }
                     FX_CALL(
                        _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(elemtyp_1, elemtyp1_0, &eloc1_8,
                           &v_447, 0), _fx_catch_162);
                     _fx_make_T2N10Ast__typ_tR10Ast__loc_t(arrtyp1_0, loc_0, &v_448);
                     FX_CALL(
                        _fx_M3AstFM8ExpUnaryN10Ast__exp_t3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                           &_fx_g23Ast_typecheck__OpExpand, e1_5, &v_448, &v_449), _fx_catch_162);
                     _fx_make_T4BiN10Ast__exp_tR10Ast__loc_t(true, d_0, v_449, loc_0, &v_436);

                  _fx_catch_162: ;
                     if (v_449) {
                        _fx_free_N10Ast__exp_t(&v_449);
                     }
                     _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_448);
                     FX_FREE_STR(&v_447);
                     FX_FREE_STR(&v_446);
                     fx_free_exn(&v_445);
                     if (elemtyp1_0) {
                        _fx_free_N10Ast__typ_t(&elemtyp1_0);
                     }
                     FX_FREE_STR(&collname_0);
                     _fx_free_T3SiN10Ast__typ_t(&v_444);
                     if (v_443) {
                        _fx_free_N10Ast__typ_t(&v_443);
                     }
                     if (arrtyp1_0) {
                        _fx_free_N10Ast__typ_t(&arrtyp1_0);
                     }
                     _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_442);
                     if (e1_5) {
                        _fx_free_N10Ast__exp_t(&e1_5);
                     }
                     goto _fx_endmatch_32;
                  }
               }
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_452 = {0};
               _fx_N10Ast__typ_t elemtyp1_1 = 0;
               _fx_N10Ast__exp_t v_453 = 0;
               FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(elem_0, &v_452, 0), _fx_catch_163);
               FX_COPY_PTR(v_452.t0, &elemtyp1_1);
               _fx_R10Ast__loc_t eloc1_9 = v_452.t1;
               fx_str_t slit_180 = FX_MAKE_STR("all the scalar elements of the array should have the same type");
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(elemtyp_1, elemtyp1_1, &eloc1_9,
                     &slit_180, 0), _fx_catch_163);
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     elem_0, &env_2, sc_2, &v_453, 0), _fx_catch_163);
               _fx_make_T4BiN10Ast__exp_tR10Ast__loc_t(false, 1, v_453, &eloc1_9, &v_436);

            _fx_catch_163: ;
               if (v_453) {
                  _fx_free_N10Ast__exp_t(&v_453);
               }
               if (elemtyp1_1) {
                  _fx_free_N10Ast__typ_t(&elemtyp1_1);
               }
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_452);

            _fx_endmatch_32: ;
               FX_CHECK_EXN(_fx_catch_164);
               bool is_expanded_0 = v_436.t0;
               int_ elem_dims_0 = v_436.t1;
               FX_COPY_PTR(v_436.t2, &elem1_0);
               _fx_R10Ast__loc_t elem_loc_0 = v_436.t3;
               int_ row_dims_1;
               if (row_dims_0 >= 0) {
                  row_dims_1 = row_dims_0;
               }
               else {
                  row_dims_1 = elem_dims_0;
               }
               if (row_dims_1 != elem_dims_0) {
                  FX_CALL(_fx_F6stringS1i(elem_dims_0, &v_437, 0), _fx_catch_164);
                  FX_CALL(_fx_F6stringS1i(row_dims_1, &v_438, 0), _fx_catch_164);
                  fx_str_t slit_181 = FX_MAKE_STR("dimensionality of array element (=");
                  fx_str_t slit_182 = FX_MAKE_STR(") does not match the previous elements dimensionality (=");
                  fx_str_t slit_183 = FX_MAKE_STR(") in the same row");
                  {
                     const fx_str_t strs_22[] = { slit_181, v_437, slit_182, v_438, slit_183 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_22, 5, &v_439), _fx_catch_164);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&elem_loc_0, &v_439, &v_440, 0), _fx_catch_164);
                  FX_THROW(&v_440, false, _fx_catch_164);
               }
               bool t_13;
               if (v_435.t0) {
                  t_13 = true;
               }
               else {
                  t_13 = is_expanded_0;
               }
               FX_CALL(_fx_cons_LN10Ast__exp_t(elem1_0, arow_2, false, &arow_2), _fx_catch_164);
               _fx_make_T3BiLN10Ast__exp_t(t_13, row_dims_1, arow_2, &v_441);
               _fx_free_T3BiLN10Ast__exp_t(&__fold_result___6);
               _fx_copy_T3BiLN10Ast__exp_t(&v_441, &__fold_result___6);

            _fx_catch_164: ;
               _fx_free_T3BiLN10Ast__exp_t(&v_441);
               fx_free_exn(&v_440);
               FX_FREE_STR(&v_439);
               FX_FREE_STR(&v_438);
               FX_FREE_STR(&v_437);
               if (elem1_0) {
                  _fx_free_N10Ast__exp_t(&elem1_0);
               }
               _fx_free_T4BiN10Ast__exp_tR10Ast__loc_t(&v_436);
               if (arow_2) {
                  _fx_free_LN10Ast__exp_t(&arow_2);
               }
               _fx_free_T3BiLN10Ast__exp_t(&v_435);
               FX_CHECK_EXN(_fx_catch_168);
            }
            _fx_copy_T3BiLN10Ast__exp_t(&__fold_result___6, &v_421);
            bool have_expanded_i_0 = v_421.t0;
            int_ row_dims_2 = v_421.t1;
            FX_COPY_PTR(v_421.t2, &arow_0);
            int_ ncols_i_0;
            FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__exp_t(arow_0, &ncols_i_0, 0), _fx_catch_168);
            _fx_R10Ast__loc_t elem_loc_1;
            if (arow_0 != 0) {
               FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(arow_0->hd, &elem_loc_1, 0), _fx_catch_165);

            _fx_catch_165: ;
            }
            else {
               if (arows_2 != 0) {
                  _fx_N10Ast__exp_t v_454 = 0;
                  FX_CALL(_fx_M13Ast_typecheckFM4lastN10Ast__exp_t1LN10Ast__exp_t(arows_2->hd, &v_454, 0), _fx_catch_166);
                  FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(v_454, &elem_loc_1, 0), _fx_catch_166);

               _fx_catch_166: ;
                  if (v_454) {
                     _fx_free_N10Ast__exp_t(&v_454);
                  }
               }
               else {
                  elem_loc_1 = eloc_0;
               }
               FX_CHECK_EXN(_fx_catch_167);

            _fx_catch_167: ;
            }
            FX_CHECK_EXN(_fx_catch_168);
            if (ncols_i_0 == 0) {
               FX_CALL(_fx_F6stringS1i(k_0 + 1, &v_422, 0), _fx_catch_168);
               FX_CALL(_fx_M6StringFM10num_suffixS1i(k_0 + 1, &v_423, 0), _fx_catch_168);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_423, &v_424, 0), _fx_catch_168);
               fx_str_t slit_184 = FX_MAKE_STR("the ");
               fx_str_t slit_185 = FX_MAKE_STR("-");
               fx_str_t slit_186 = FX_MAKE_STR(" matrix row is empty");
               {
                  const fx_str_t strs_23[] = { slit_184, v_422, slit_185, v_424, slit_186 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_23, 5, &v_425), _fx_catch_168);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&elem_loc_1, &v_425, &v_426, 0), _fx_catch_168);
               FX_THROW(&v_426, false, _fx_catch_168);
            }
            bool have_expanded_0;
            if (v_420.t2) {
               have_expanded_0 = true;
            }
            else {
               have_expanded_0 = have_expanded_i_0;
            }
            bool t_14;
            if (!have_expanded_0) {
               t_14 = ncols_0 != 0;
            }
            else {
               t_14 = false;
            }
            bool t_15;
            if (t_14) {
               t_15 = ncols_0 != ncols_i_0;
            }
            else {
               t_15 = false;
            }
            if (t_15) {
               FX_CALL(_fx_F6stringS1i(k_0 + 1, &v_427, 0), _fx_catch_168);
               FX_CALL(_fx_M6StringFM10num_suffixS1i(k_0 + 1, &v_428, 0), _fx_catch_168);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_428, &v_429, 0), _fx_catch_168);
               fx_str_t slit_187 = FX_MAKE_STR("the ");
               fx_str_t slit_188 = FX_MAKE_STR("-");
               fx_str_t slit_189 = FX_MAKE_STR(" matrix row contains a different number of elements");
               {
                  const fx_str_t strs_24[] = { slit_187, v_427, slit_188, v_429, slit_189 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_24, 5, &v_430), _fx_catch_168);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&elem_loc_1, &v_430, &v_431, 0), _fx_catch_168);
               FX_THROW(&v_431, false, _fx_catch_168);
            }
            int_ dims_1;
            if (v_420.t3 < 0) {
               dims_1 = row_dims_2;
            }
            else {
               dims_1 = 2;
            }
            int_ t_16;
            if (have_expanded_i_0) {
               t_16 = ncols_i_0;
            }
            else {
               t_16 = ncols_0;
            }
            FX_CALL(_fx_M13Ast_typecheckFM3revLN10Ast__exp_t1LN10Ast__exp_t(arow_0, &v_432, 0), _fx_catch_168);
            FX_CALL(_fx_cons_LLN10Ast__exp_t(v_432, arows_2, true, &v_433), _fx_catch_168);
            _fx_make_T4iLLN10Ast__exp_tBi(t_16, v_433, have_expanded_0, dims_1, &v_434);
            _fx_free_T4iLLN10Ast__exp_tBi(&__fold_result___5);
            _fx_copy_T4iLLN10Ast__exp_tBi(&v_434, &__fold_result___5);

         _fx_catch_168: ;
            _fx_free_T4iLLN10Ast__exp_tBi(&v_434);
            if (v_433) {
               _fx_free_LLN10Ast__exp_t(&v_433);
            }
            if (v_432) {
               _fx_free_LN10Ast__exp_t(&v_432);
            }
            fx_free_exn(&v_431);
            FX_FREE_STR(&v_430);
            FX_FREE_STR(&v_429);
            FX_FREE_STR(&v_428);
            FX_FREE_STR(&v_427);
            fx_free_exn(&v_426);
            FX_FREE_STR(&v_425);
            FX_FREE_STR(&v_424);
            FX_FREE_STR(&v_423);
            FX_FREE_STR(&v_422);
            if (arow_0) {
               _fx_free_LN10Ast__exp_t(&arow_0);
            }
            _fx_free_T3BiLN10Ast__exp_t(&v_421);
            _fx_free_T3BiLN10Ast__exp_t(&__fold_result___6);
            if (arows_2) {
               _fx_free_LLN10Ast__exp_t(&arows_2);
            }
            _fx_free_T4iLLN10Ast__exp_tBi(&v_420);
            FX_CHECK_EXN(_fx_catch_169);
         }
         _fx_copy_T4iLLN10Ast__exp_tBi(&__fold_result___5, &v_418);
         FX_COPY_PTR(v_418.t1, &arows_1);
         int_ dims_2 = v_418.t3;
         FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(dims_2, elemtyp_1, &atyp_0), _fx_catch_169);
         fx_str_t slit_190 = FX_MAKE_STR("the array literal should produce an array");
         FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(atyp_0, etyp_0, &eloc_0, &slit_190, 0),
            _fx_catch_169);
         FX_CALL(_fx_M13Ast_typecheckFM3revLLN10Ast__exp_t1LLN10Ast__exp_t(arows_1, &v_419, 0), _fx_catch_169);
         FX_CALL(_fx_M3AstFM10ExpMkArrayN10Ast__exp_t2LLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_419, &ctx_0, &result_46),
            _fx_catch_169);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_46, &result_0);
         FX_BREAK(_fx_catch_169);

      _fx_catch_169: ;
         if (result_46) {
            _fx_free_N10Ast__exp_t(&result_46);
         }
         if (v_419) {
            _fx_free_LLN10Ast__exp_t(&v_419);
         }
         if (atyp_0) {
            _fx_free_N10Ast__typ_t(&atyp_0);
         }
         if (arows_1) {
            _fx_free_LLN10Ast__exp_t(&arows_1);
         }
         _fx_free_T4iLLN10Ast__exp_tBi(&v_418);
         if (arows_0) {
            _fx_free_LLN10Ast__exp_t(&arows_0);
         }
         _fx_free_T4iLLN10Ast__exp_tBi(&__fold_result___5);
         if (elemtyp_1) {
            _fx_free_N10Ast__typ_t(&elemtyp_1);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 15) {
         _fx_N10Ast__typ_t elemtyp_2 = 0;
         _fx_LN10Ast__exp_t __fold_result___7 = 0;
         _fx_LN10Ast__exp_t elems_1 = 0;
         _fx_LN10Ast__exp_t elems_2 = 0;
         _fx_N10Ast__typ_t vectyp_0 = 0;
         _fx_LN10Ast__exp_t v_455 = 0;
         _fx_N10Ast__exp_t result_47 = 0;
         FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&elemtyp_2, 0), _fx_catch_174);
         FX_COPY_PTR(e_2->u.ExpMkVector.t0, &elems_1);
         _fx_LN10Ast__exp_t lst_17 = elems_1;
         for (; lst_17; lst_17 = lst_17->tl) {
            _fx_LN10Ast__exp_t elems_3 = 0;
            _fx_LN10Ast__exp_t v_456 = 0;
            _fx_N10Ast__exp_t elem_1 = lst_17->hd;
            FX_COPY_PTR(__fold_result___7, &elems_3);
            if (FX_REC_VARIANT_TAG(elem_1) == 9) {
               _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_29 = &elem_1->u.ExpUnary;
               if (vcase_29->t0.tag == 8) {
                  _fx_N10Ast__exp_t e1_6 = 0;
                  _fx_T2N10Ast__typ_tR10Ast__loc_t v_457 = {0};
                  _fx_N10Ast__typ_t etyp1_11 = 0;
                  _fx_N10Ast__typ_t v_458 = 0;
                  _fx_T2SN10Ast__typ_t v_459 = {0};
                  fx_str_t collname_1 = {0};
                  _fx_N10Ast__typ_t elemtyp1_2 = 0;
                  fx_str_t v_460 = {0};
                  fx_str_t v_461 = {0};
                  _fx_T2N10Ast__typ_tR10Ast__loc_t v_462 = {0};
                  _fx_N10Ast__exp_t v_463 = 0;
                  _fx_T2N10Ast__typ_tR10Ast__loc_t* v_464 = &vcase_29->t2;
                  _fx_N10Ast__typ_t t_17 = v_464->t0;
                  FX_CALL(
                     _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                        vcase_29->t1, &env_2, sc_2, &e1_6, 0), _fx_catch_171);
                  FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_6, &v_457, 0), _fx_catch_171);
                  FX_COPY_PTR(v_457.t0, &etyp1_11);
                  _fx_R10Ast__loc_t eloc1_10 = v_457.t1;
                  fx_str_t slit_191 = FX_MAKE_STR("incorrect type of expanded collection");
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t_17, etyp1_11, &eloc1_10,
                        &slit_191, 0), _fx_catch_171);
                  FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp1_11, &v_458, 0), _fx_catch_171);
                  int tag_13 = FX_REC_VARIANT_TAG(v_458);
                  if (tag_13 == 19) {
                     _fx_T2iN10Ast__typ_t* vcase_30 = &v_458->u.TypArray;
                     if (vcase_30->t0 == 1) {
                        fx_str_t slit_192 = FX_MAKE_STR("array");
                        _fx_make_T2SN10Ast__typ_t(&slit_192, vcase_30->t1, &v_459);
                        goto _fx_endmatch_33;
                     }
                  }
                  if (tag_13 == 16) {
                     fx_str_t slit_193 = FX_MAKE_STR("vector");
                     _fx_make_T2SN10Ast__typ_t(&slit_193, v_458->u.TypVector, &v_459);
                     goto _fx_endmatch_33;
                  }
                  if (tag_13 == 15) {
                     fx_str_t slit_194 = FX_MAKE_STR("list");
                     _fx_make_T2SN10Ast__typ_t(&slit_194, v_458->u.TypList, &v_459);
                     goto _fx_endmatch_33;
                  }
                  if (tag_13 == 10) {
                     fx_str_t slit_195 = FX_MAKE_STR("string");
                     _fx_make_T2SN10Ast__typ_t(&slit_195, _fx_g22Ast_typecheck__TypChar, &v_459);
                     goto _fx_endmatch_33;
                  }
                  fx_exn_t v_465 = {0};
                  fx_str_t slit_196 =
                     FX_MAKE_STR(
                        "incorrect type \'{typ2str(etyp1)} of the expanded collection (it should be an 1D array, list or string)");
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc1_10, &slit_196, &v_465, 0), _fx_catch_170);
                  FX_THROW(&v_465, false, _fx_catch_170);

               _fx_catch_170: ;
                  fx_free_exn(&v_465);

               _fx_endmatch_33: ;
                  FX_CHECK_EXN(_fx_catch_171);
                  fx_copy_str(&v_459.t0, &collname_1);
                  FX_COPY_PTR(v_459.t1, &elemtyp1_2);
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&collname_1, &v_460, 0), _fx_catch_171);
                  fx_str_t slit_197 = FX_MAKE_STR("the expanded \'");
                  fx_str_t slit_198 = FX_MAKE_STR("\' elem type does not match the previous elements");
                  {
                     const fx_str_t strs_25[] = { slit_197, v_460, slit_198 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_25, 3, &v_461), _fx_catch_171);
                  }
                  FX_CALL(
                     _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(elemtyp_2, elemtyp1_2, &eloc1_10,
                        &v_461, 0), _fx_catch_171);
                  _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t_17, &v_464->t1, &v_462);
                  FX_CALL(
                     _fx_M3AstFM8ExpUnaryN10Ast__exp_t3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                        &_fx_g23Ast_typecheck__OpExpand, e1_6, &v_462, &v_463), _fx_catch_171);
                  FX_CALL(_fx_cons_LN10Ast__exp_t(v_463, elems_3, true, &v_456), _fx_catch_171);

               _fx_catch_171: ;
                  if (v_463) {
                     _fx_free_N10Ast__exp_t(&v_463);
                  }
                  _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_462);
                  FX_FREE_STR(&v_461);
                  FX_FREE_STR(&v_460);
                  if (elemtyp1_2) {
                     _fx_free_N10Ast__typ_t(&elemtyp1_2);
                  }
                  FX_FREE_STR(&collname_1);
                  _fx_free_T2SN10Ast__typ_t(&v_459);
                  if (v_458) {
                     _fx_free_N10Ast__typ_t(&v_458);
                  }
                  if (etyp1_11) {
                     _fx_free_N10Ast__typ_t(&etyp1_11);
                  }
                  _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_457);
                  if (e1_6) {
                     _fx_free_N10Ast__exp_t(&e1_6);
                  }
                  goto _fx_endmatch_34;
               }
            }
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_466 = {0};
            _fx_N10Ast__typ_t elemtyp1_3 = 0;
            _fx_N10Ast__exp_t v_467 = 0;
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(elem_1, &v_466, 0), _fx_catch_172);
            FX_COPY_PTR(v_466.t0, &elemtyp1_3);
            _fx_R10Ast__loc_t eloc1_11 = v_466.t1;
            fx_str_t slit_199 = FX_MAKE_STR("all the scalar elements of the vector should have the same type");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(elemtyp_2, elemtyp1_3, &eloc1_11,
                  &slit_199, 0), _fx_catch_172);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  elem_1, &env_2, sc_2, &v_467, 0), _fx_catch_172);
            FX_CALL(_fx_cons_LN10Ast__exp_t(v_467, elems_3, true, &v_456), _fx_catch_172);

         _fx_catch_172: ;
            if (v_467) {
               _fx_free_N10Ast__exp_t(&v_467);
            }
            if (elemtyp1_3) {
               _fx_free_N10Ast__typ_t(&elemtyp1_3);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_466);

         _fx_endmatch_34: ;
            FX_CHECK_EXN(_fx_catch_173);
            _fx_free_LN10Ast__exp_t(&__fold_result___7);
            FX_COPY_PTR(v_456, &__fold_result___7);

         _fx_catch_173: ;
            if (v_456) {
               _fx_free_LN10Ast__exp_t(&v_456);
            }
            if (elems_3) {
               _fx_free_LN10Ast__exp_t(&elems_3);
            }
            FX_CHECK_EXN(_fx_catch_174);
         }
         FX_COPY_PTR(__fold_result___7, &elems_2);
         FX_CALL(_fx_M3AstFM9TypVectorN10Ast__typ_t1N10Ast__typ_t(elemtyp_2, &vectyp_0), _fx_catch_174);
         fx_str_t slit_200 =
            FX_MAKE_STR(
               "the constructed vector has type \'{typ2str(vectype)}\', but is expected to have type \'{typ2str(etyp)}\'");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(vectyp_0, etyp_0, &eloc_0, &slit_200, 0),
            _fx_catch_174);
         FX_CALL(_fx_M13Ast_typecheckFM3revLN10Ast__exp_t1LN10Ast__exp_t(elems_2, &v_455, 0), _fx_catch_174);
         FX_CALL(_fx_M3AstFM11ExpMkVectorN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_455, &ctx_0, &result_47),
            _fx_catch_174);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_47, &result_0);
         FX_BREAK(_fx_catch_174);

      _fx_catch_174: ;
         if (result_47) {
            _fx_free_N10Ast__exp_t(&result_47);
         }
         if (v_455) {
            _fx_free_LN10Ast__exp_t(&v_455);
         }
         if (vectyp_0) {
            _fx_free_N10Ast__typ_t(&vectyp_0);
         }
         if (elems_2) {
            _fx_free_LN10Ast__exp_t(&elems_2);
         }
         if (elems_1) {
            _fx_free_LN10Ast__exp_t(&elems_1);
         }
         if (__fold_result___7) {
            _fx_free_LN10Ast__exp_t(&__fold_result___7);
         }
         if (elemtyp_2) {
            _fx_free_N10Ast__typ_t(&elemtyp_2);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 16) {
         _fx_LR9Ast__id_t v_468 = 0;
         _fx_LT2R9Ast__id_tN10Ast__exp_t r_initializers_0 = 0;
         _fx_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_469 = {0};
         _fx_LT2R9Ast__id_tN10Ast__exp_t lst_18 = 0;
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_19 = 0;
         _fx_LT2R9Ast__id_tN10Ast__exp_t r_initializers_1 = 0;
         _fx_LT2R9Ast__id_tN10Ast__exp_t r_new_initializers_0 = 0;
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_1 = 0;
         _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_470 = {0};
         _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_471 = 0;
         _fx_N10Ast__typ_t rtyp_0 = 0;
         _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_31 = &e_2->u.ExpMkRecord;
         _fx_LT2R9Ast__id_tN10Ast__exp_t r_initializers_2 = vcase_31->t1;
         _fx_N10Ast__exp_t r_e_0 = vcase_31->t0;
         _fx_LR9Ast__id_t lstend_10 = 0;
         FX_COPY_PTR(r_initializers_2, &r_initializers_0);
         _fx_LT2R9Ast__id_tN10Ast__exp_t lst_20 = r_initializers_0;
         for (; lst_20; lst_20 = lst_20->tl) {
            _fx_T2R9Ast__id_tN10Ast__exp_t* __pat___3 = &lst_20->hd;
            _fx_LR9Ast__id_t node_10 = 0;
            FX_CALL(_fx_cons_LR9Ast__id_t(&__pat___3->t0, 0, false, &node_10), _fx_catch_175);
            FX_LIST_APPEND(v_468, lstend_10, node_10);

         _fx_catch_175: ;
            FX_CHECK_EXN(_fx_catch_179);
         }
         FX_CALL(_fx_M13Ast_typecheckFM30check_for_rec_field_duplicatesv2LR9Ast__id_tR10Ast__loc_t(v_468, &eloc_0, 0),
            _fx_catch_179);
         _fx_LT2R9Ast__id_tN10Ast__exp_t lstend_11 = 0;
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lstend_12 = 0;
         FX_COPY_PTR(r_initializers_2, &r_initializers_1);
         _fx_LT2R9Ast__id_tN10Ast__exp_t lst_21 = r_initializers_1;
         for (; lst_21; lst_21 = lst_21->tl) {
            _fx_N10Ast__exp_t e_7 = 0;
            _fx_N10Ast__exp_t e_8 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_472 = {0};
            _fx_N10Ast__typ_t etypi_0 = 0;
            _fx_T2R9Ast__id_tN10Ast__exp_t v_473 = {0};
            _fx_R16Ast__val_flags_t v_474 = {0};
            _fx_N10Ast__exp_t v_475 = 0;
            _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_476 = {0};
            _fx_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t tup_0 = {0};
            _fx_T2R9Ast__id_tN10Ast__exp_t* __pat___4 = &lst_21->hd;
            _fx_R9Ast__id_t n_1 = __pat___4->t0;
            FX_COPY_PTR(__pat___4->t1, &e_7);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  e_7, &env_2, sc_2, &e_8, 0), _fx_catch_176);
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e_8, &v_472, 0), _fx_catch_176);
            FX_COPY_PTR(v_472.t0, &etypi_0);
            _fx_R10Ast__loc_t eloci_0 = v_472.t1;
            _fx_make_T2R9Ast__id_tN10Ast__exp_t(&n_1, e_8, &v_473);
            FX_CALL(_fx_M3AstFM17default_val_flagsRM11val_flags_t0(&v_474, 0), _fx_catch_176);
            FX_CALL(_fx_M3AstFM6ExpNopN10Ast__exp_t1RM5loc_t(&eloci_0, &v_475), _fx_catch_176);
            _fx_make_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_474, &n_1, etypi_0, v_475, &v_476);
            _fx_make_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_473, &v_476,
               &tup_0);
            _fx_LT2R9Ast__id_tN10Ast__exp_t node_11 = 0;
            FX_CALL(_fx_cons_LT2R9Ast__id_tN10Ast__exp_t(&tup_0.t0, 0, false, &node_11), _fx_catch_176);
            FX_LIST_APPEND(lst_18, lstend_11, node_11);
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t node_12 = 0;
            FX_CALL(_fx_cons_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&tup_0.t1, 0, false, &node_12),
               _fx_catch_176);
            FX_LIST_APPEND(lst_19, lstend_12, node_12);

         _fx_catch_176: ;
            _fx_free_T2T2R9Ast__id_tN10Ast__exp_tT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&tup_0);
            _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_476);
            if (v_475) {
               _fx_free_N10Ast__exp_t(&v_475);
            }
            _fx_free_R16Ast__val_flags_t(&v_474);
            _fx_free_T2R9Ast__id_tN10Ast__exp_t(&v_473);
            if (etypi_0) {
               _fx_free_N10Ast__typ_t(&etypi_0);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_472);
            if (e_8) {
               _fx_free_N10Ast__exp_t(&e_8);
            }
            if (e_7) {
               _fx_free_N10Ast__exp_t(&e_7);
            }
            FX_CHECK_EXN(_fx_catch_179);
         }
         _fx_make_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(lst_18, lst_19,
            &v_469);
         FX_COPY_PTR(v_469.t0, &r_new_initializers_0);
         FX_COPY_PTR(v_469.t1, &relems_1);
         _fx_make_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(relems_1, false, &v_470);
         FX_CALL(_fx_make_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_470, &v_471), _fx_catch_179);
         FX_CALL(_fx_M3AstFM9TypRecordN10Ast__typ_t1rT2LT4RM11val_flags_tRM4id_tN10Ast__typ_tN10Ast__exp_tB(v_471, &rtyp_0),
            _fx_catch_179);
         if (FX_REC_VARIANT_TAG(r_e_0) == 1) {
            _fx_N10Ast__exp_t result_48 = 0;
            fx_str_t slit_201 = FX_MAKE_STR("unexpected record type");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, rtyp_0, &eloc_0, &slit_201, 0),
               _fx_catch_177);
            FX_CALL(
               _fx_M3AstFM11ExpMkRecordN10Ast__exp_t3N10Ast__exp_tLT2RM4id_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(r_e_0,
                  r_new_initializers_0, &ctx_0, &result_48), _fx_catch_177);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_48, &result_0);
            FX_BREAK(_fx_catch_177);

         _fx_catch_177: ;
            if (result_48) {
               _fx_free_N10Ast__exp_t(&result_48);
            }
         }
         else {
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_477 = {0};
            _fx_N10Ast__typ_t r_etyp_0 = 0;
            _fx_LN10Ast__typ_t v_478 = 0;
            _fx_N10Ast__typ_t r_expected_typ_0 = 0;
            _fx_N10Ast__exp_t new_r_e_0 = 0;
            _fx_N10Ast__exp_t result_49 = 0;
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(r_e_0, &v_477, 0), _fx_catch_178);
            FX_COPY_PTR(v_477.t0, &r_etyp_0);
            _fx_R10Ast__loc_t r_eloc_0 = v_477.t1;
            FX_CALL(_fx_cons_LN10Ast__typ_t(rtyp_0, 0, true, &v_478), _fx_catch_178);
            FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(v_478, etyp_0, &r_expected_typ_0),
               _fx_catch_178);
            fx_str_t slit_202 = FX_MAKE_STR("there is no proper record constructor/function with record argument");
            FX_CALL(
               _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(r_etyp_0, r_expected_typ_0, &r_eloc_0,
                  &slit_202, 0), _fx_catch_178);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                  r_e_0, &env_2, sc_2, &new_r_e_0, 0), _fx_catch_178);
            FX_CALL(
               _fx_M3AstFM11ExpMkRecordN10Ast__exp_t3N10Ast__exp_tLT2RM4id_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_r_e_0,
                  r_new_initializers_0, &ctx_0, &result_49), _fx_catch_178);
            _fx_free_N10Ast__exp_t(&result_0);
            FX_COPY_PTR(result_49, &result_0);
            FX_BREAK(_fx_catch_178);

         _fx_catch_178: ;
            if (result_49) {
               _fx_free_N10Ast__exp_t(&result_49);
            }
            if (new_r_e_0) {
               _fx_free_N10Ast__exp_t(&new_r_e_0);
            }
            if (r_expected_typ_0) {
               _fx_free_N10Ast__typ_t(&r_expected_typ_0);
            }
            if (v_478) {
               _fx_free_LN10Ast__typ_t(&v_478);
            }
            if (r_etyp_0) {
               _fx_free_N10Ast__typ_t(&r_etyp_0);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_477);
         }
         FX_CHECK_EXN(_fx_catch_179);

      _fx_catch_179: ;
         if (rtyp_0) {
            _fx_free_N10Ast__typ_t(&rtyp_0);
         }
         if (v_471) {
            _fx_free_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_471);
         }
         _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_470);
         if (relems_1) {
            _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_1);
         }
         if (r_new_initializers_0) {
            _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&r_new_initializers_0);
         }
         if (r_initializers_1) {
            _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&r_initializers_1);
         }
         if (lst_19) {
            _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&lst_19);
         }
         if (lst_18) {
            _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&lst_18);
         }
         _fx_free_T2LT2R9Ast__id_tN10Ast__exp_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_469);
         if (r_initializers_0) {
            _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&r_initializers_0);
         }
         FX_FREE_LIST_SIMPLE(&v_468);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 17) {
         _fx_LR9Ast__id_t v_479 = 0;
         _fx_LT2R9Ast__id_tN10Ast__exp_t r_initializers_3 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_480 = {0};
         _fx_N10Ast__typ_t rtyp_1 = 0;
         _fx_N10Ast__exp_t new_r_e_1 = 0;
         _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_481 = {0};
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_2 = 0;
         _fx_LT2R9Ast__id_tN10Ast__exp_t new_r_initializers_0 = 0;
         _fx_LT2R9Ast__id_tN10Ast__exp_t r_initializers_4 = 0;
         _fx_N10Ast__exp_t result_50 = 0;
         _fx_T3N10Ast__exp_tLT2R9Ast__id_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_32 = &e_2->u.ExpUpdateRecord;
         _fx_LT2R9Ast__id_tN10Ast__exp_t r_initializers_5 = vcase_32->t1;
         _fx_N10Ast__exp_t r_e_1 = vcase_32->t0;
         _fx_LR9Ast__id_t lstend_13 = 0;
         FX_COPY_PTR(r_initializers_5, &r_initializers_3);
         _fx_LT2R9Ast__id_tN10Ast__exp_t lst_22 = r_initializers_3;
         for (; lst_22; lst_22 = lst_22->tl) {
            _fx_T2R9Ast__id_tN10Ast__exp_t* __pat___5 = &lst_22->hd;
            _fx_LR9Ast__id_t node_13 = 0;
            FX_CALL(_fx_cons_LR9Ast__id_t(&__pat___5->t0, 0, false, &node_13), _fx_catch_180);
            FX_LIST_APPEND(v_479, lstend_13, node_13);

         _fx_catch_180: ;
            FX_CHECK_EXN(_fx_catch_184);
         }
         FX_CALL(_fx_M13Ast_typecheckFM30check_for_rec_field_duplicatesv2LR9Ast__id_tR10Ast__loc_t(v_479, &eloc_0, 0),
            _fx_catch_184);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(r_e_1, &v_480, 0), _fx_catch_184);
         FX_COPY_PTR(v_480.t0, &rtyp_1);
         _fx_R10Ast__loc_t rloc_0 = v_480.t1;
         fx_str_t slit_203 = FX_MAKE_STR("the types of the update-record argument and the result do not match");
         FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(rtyp_1, etyp_0, &eloc_0, &slit_203, 0),
            _fx_catch_184);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               r_e_1, &env_2, sc_2, &new_r_e_1, 0), _fx_catch_184);
         FX_CALL(
            _fx_M13Ast_typecheckFM16get_record_elemsT2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t4Nt6option1R9Ast__id_tN10Ast__typ_tBR10Ast__loc_t(
               &_fx_g21Ast_typecheck__None9_, rtyp_1, false, &rloc_0, &v_481, 0), _fx_catch_184);
         FX_COPY_PTR(v_481.t1, &relems_2);
         _fx_LT2R9Ast__id_tN10Ast__exp_t lstend_14 = 0;
         FX_COPY_PTR(r_initializers_5, &r_initializers_4);
         _fx_LT2R9Ast__id_tN10Ast__exp_t lst_23 = r_initializers_4;
         for (; lst_23; lst_23 = lst_23->tl) {
            _fx_N10Ast__exp_t ei_0 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_482 = {0};
            _fx_N10Ast__typ_t ei_typ_0 = 0;
            _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t __lambda___1 = {0};
            _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_483 = {0};
            _fx_T2R9Ast__id_tN10Ast__exp_t res_37 = {0};
            _fx_T2R9Ast__id_tN10Ast__exp_t* __pat___6 = &lst_23->hd;
            _fx_R9Ast__id_t ni_0 = __pat___6->t0;
            FX_COPY_PTR(__pat___6->t1, &ei_0);
            FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(ei_0, &v_482, 0), _fx_catch_183);
            FX_COPY_PTR(v_482.t0, &ei_typ_0);
            _fx_R10Ast__loc_t ei_loc_0 = v_482.t1;
            _fx_M13Ast_typecheckFM9make_fp1_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1R9Ast__id_t(&ni_0,
               &__lambda___1);
            FX_CALL(
               _fx_M13Ast_typecheckFM8find_optNt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tFPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
                  relems_2, &__lambda___1, &v_483, 0), _fx_catch_183);
            if (v_483.tag == 2) {
               fx_str_t v_484 = {0};
               fx_str_t v_485 = {0};
               fx_str_t v_486 = {0};
               _fx_N10Ast__exp_t new_ei_0 = 0;
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&ni_0, &v_484, 0), _fx_catch_181);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_484, &v_485, 0), _fx_catch_181);
               fx_str_t slit_204 = FX_MAKE_STR("invalid type of the initializer of record field \'");
               fx_str_t slit_205 = FX_MAKE_STR("\'");
               {
                  const fx_str_t strs_26[] = { slit_204, v_485, slit_205 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_26, 3, &v_486), _fx_catch_181);
               }
               FX_CALL(
                  _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(v_483.u.Some.t2, ei_typ_0, &ei_loc_0,
                     &v_486, 0), _fx_catch_181);
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     ei_0, &env_2, sc_2, &new_ei_0, 0), _fx_catch_181);
               _fx_make_T2R9Ast__id_tN10Ast__exp_t(&ni_0, new_ei_0, &res_37);

            _fx_catch_181: ;
               if (new_ei_0) {
                  _fx_free_N10Ast__exp_t(&new_ei_0);
               }
               FX_FREE_STR(&v_486);
               FX_FREE_STR(&v_485);
               FX_FREE_STR(&v_484);
            }
            else {
               fx_str_t v_487 = {0};
               fx_str_t v_488 = {0};
               fx_str_t v_489 = {0};
               fx_exn_t v_490 = {0};
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&ni_0, &v_487, 0), _fx_catch_182);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_487, &v_488, 0), _fx_catch_182);
               fx_str_t slit_206 = FX_MAKE_STR("there is no record field \'");
               fx_str_t slit_207 = FX_MAKE_STR("\' in the updated record");
               {
                  const fx_str_t strs_27[] = { slit_206, v_488, slit_207 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_27, 3, &v_489), _fx_catch_182);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&ei_loc_0, &v_489, &v_490, 0), _fx_catch_182);
               FX_THROW(&v_490, false, _fx_catch_182);

            _fx_catch_182: ;
               fx_free_exn(&v_490);
               FX_FREE_STR(&v_489);
               FX_FREE_STR(&v_488);
               FX_FREE_STR(&v_487);
            }
            FX_CHECK_EXN(_fx_catch_183);
            _fx_LT2R9Ast__id_tN10Ast__exp_t node_14 = 0;
            FX_CALL(_fx_cons_LT2R9Ast__id_tN10Ast__exp_t(&res_37, 0, false, &node_14), _fx_catch_183);
            FX_LIST_APPEND(new_r_initializers_0, lstend_14, node_14);

         _fx_catch_183: ;
            _fx_free_T2R9Ast__id_tN10Ast__exp_t(&res_37);
            _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_483);
            FX_FREE_FP(&__lambda___1);
            if (ei_typ_0) {
               _fx_free_N10Ast__typ_t(&ei_typ_0);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_482);
            if (ei_0) {
               _fx_free_N10Ast__exp_t(&ei_0);
            }
            FX_CHECK_EXN(_fx_catch_184);
         }
         FX_CALL(
            _fx_M3AstFM15ExpUpdateRecordN10Ast__exp_t3N10Ast__exp_tLT2RM4id_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_r_e_1,
               new_r_initializers_0, &ctx_0, &result_50), _fx_catch_184);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_50, &result_0);
         FX_BREAK(_fx_catch_184);

      _fx_catch_184: ;
         if (result_50) {
            _fx_free_N10Ast__exp_t(&result_50);
         }
         if (r_initializers_4) {
            _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&r_initializers_4);
         }
         if (new_r_initializers_0) {
            _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&new_r_initializers_0);
         }
         if (relems_2) {
            _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_2);
         }
         _fx_free_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_481);
         if (new_r_e_1) {
            _fx_free_N10Ast__exp_t(&new_r_e_1);
         }
         if (rtyp_1) {
            _fx_free_N10Ast__typ_t(&rtyp_1);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_480);
         if (r_initializers_3) {
            _fx_free_LT2R9Ast__id_tN10Ast__exp_t(&r_initializers_3);
         }
         FX_FREE_LIST_SIMPLE(&v_479);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 28) {
         _fx_LN12Ast__scope_t sc_3 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_491 = {0};
         _fx_N10Ast__typ_t e1typ_0 = 0;
         _fx_N10Ast__exp_t new_e1_12 = 0;
         _fx_LT2N10Ast__pat_tN10Ast__exp_t new_cases_0 = 0;
         _fx_N10Ast__exp_t result_51 = 0;
         _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_33 = &e_2->u.ExpTryCatch;
         _fx_N10Ast__exp_t e1_7 = vcase_33->t0;
         _fx_N12Ast__scope_t v_492;
         FX_CALL(_fx_M3AstFM13new_try_scopeN12Ast__scope_t1i(curr_m_idx_0, &v_492, 0), _fx_catch_185);
         FX_CALL(_fx_cons_LN12Ast__scope_t(&v_492, sc_2, true, &sc_3), _fx_catch_185);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_7, &v_491, 0), _fx_catch_185);
         FX_COPY_PTR(v_491.t0, &e1typ_0);
         _fx_R10Ast__loc_t e1loc_0 = v_491.t1;
         fx_str_t slit_208 = FX_MAKE_STR("try body type does match the whole try-catch type");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, e1typ_0, &e1loc_0, &slit_208, 0),
            _fx_catch_185);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e1_7, &env_2, sc_3, &new_e1_12, 0), _fx_catch_185);
         FX_CALL(
            _fx_M13Ast_typecheckFM11check_casesLT2N10Ast__pat_tN10Ast__exp_t6LT2N10Ast__pat_tN10Ast__exp_tN10Ast__typ_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               vcase_33->t1, _fx_g21Ast_typecheck__TypExn, etyp_0, &env_2, sc_3, &eloc_0, &new_cases_0, 0), _fx_catch_185);
         FX_CALL(
            _fx_M3AstFM11ExpTryCatchN10Ast__exp_t3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_e1_12,
               new_cases_0, &ctx_0, &result_51), _fx_catch_185);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_51, &result_0);
         FX_BREAK(_fx_catch_185);

      _fx_catch_185: ;
         if (result_51) {
            _fx_free_N10Ast__exp_t(&result_51);
         }
         if (new_cases_0) {
            _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&new_cases_0);
         }
         if (new_e1_12) {
            _fx_free_N10Ast__exp_t(&new_e1_12);
         }
         if (e1typ_0) {
            _fx_free_N10Ast__typ_t(&e1typ_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_491);
         FX_FREE_LIST_SIMPLE(&sc_3);
         goto _fx_endmatch_41;
      }
      if (tag_0 == 29) {
         _fx_N10Ast__exp_t new_e1_13 = 0;
         _fx_N10Ast__typ_t new_e1typ_0 = 0;
         _fx_LT2N10Ast__pat_tN10Ast__exp_t new_cases_1 = 0;
         _fx_N10Ast__exp_t result_52 = 0;
         _fx_T3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_34 = &e_2->u.ExpMatch;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               vcase_34->t0, &env_2, sc_2, &new_e1_13, 0), _fx_catch_186);
         FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(new_e1_13, &new_e1typ_0, 0), _fx_catch_186);
         FX_CALL(
            _fx_M13Ast_typecheckFM11check_casesLT2N10Ast__pat_tN10Ast__exp_t6LT2N10Ast__pat_tN10Ast__exp_tN10Ast__typ_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               vcase_34->t1, new_e1typ_0, etyp_0, &env_2, sc_2, &eloc_0, &new_cases_1, 0), _fx_catch_186);
         FX_CALL(
            _fx_M3AstFM8ExpMatchN10Ast__exp_t3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_e1_13,
               new_cases_1, &ctx_0, &result_52), _fx_catch_186);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_52, &result_0);
         FX_BREAK(_fx_catch_186);

      _fx_catch_186: ;
         if (result_52) {
            _fx_free_N10Ast__exp_t(&result_52);
         }
         if (new_cases_1) {
            _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&new_cases_1);
         }
         if (new_e1typ_0) {
            _fx_free_N10Ast__typ_t(&new_e1typ_0);
         }
         if (new_e1_13) {
            _fx_free_N10Ast__exp_t(&new_e1_13);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 30) {
         _fx_N10Ast__typ_t t2_0 = 0;
         _fx_N10Ast__exp_t e1_8 = 0;
         _fx_N10Ast__typ_t t1_0 = 0;
         _fx_N10Ast__typ_t v_493 = 0;
         _fx_N10Ast__typ_t v_494 = 0;
         _fx_T2N10Ast__exp_tLN10Ast__exp_t v_495 = {0};
         _fx_N10Ast__exp_t e1_9 = 0;
         _fx_LN10Ast__exp_t code_1 = 0;
         _fx_N10Ast__typ_t v_496 = 0;
         _fx_N10Ast__typ_t v_497 = 0;
         _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t* vcase_35 = &e_2->u.ExpCast;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               vcase_35->t1, &env_2, sc_2, &eloc_0, &t2_0, 0), _fx_catch_201);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               vcase_35->t0, &env_2, sc_2, &e1_8, 0), _fx_catch_201);
         FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(e1_8, &t1_0, 0), _fx_catch_201);
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t1_0, &v_493, 0), _fx_catch_201);
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t2_0, &v_494, 0), _fx_catch_201);
         bool res_38;
         if (FX_REC_VARIANT_TAG(e1_8) == 7) {
            res_38 = true;
         }
         else if (FX_REC_VARIANT_TAG(e1_8) == 6) {
            res_38 = true;
         }
         else {
            res_38 = false;
         }
         FX_CHECK_EXN(_fx_catch_201);
         if (res_38) {
            _fx_make_T2N10Ast__exp_tLN10Ast__exp_t(e1_8, 0, &v_495); goto _fx_endmatch_35;
         }
         bool res_39;
         if (FX_REC_VARIANT_TAG(v_494) == 17) {
            res_39 = true;
         }
         else if (FX_REC_VARIANT_TAG(v_493) == 17) {
            res_39 = true;
         }
         else {
            res_39 = false;
         }
         FX_CHECK_EXN(_fx_catch_201);
         if (res_39) {
            _fx_R16Ast__val_flags_t flags_2 = {0};
            _fx_R13Ast__defval_t dv_0 = {0};
            _fx_N14Ast__id_info_t v_498 = {0};
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_499 = {0};
            _fx_N10Ast__exp_t v_500 = 0;
            _fx_N10Ast__pat_t v_501 = 0;
            _fx_N10Ast__exp_t v_502 = 0;
            _fx_LN10Ast__exp_t v_503 = 0;
            _fx_R9Ast__id_t temp_id_0;
            fx_str_t slit_209 = FX_MAKE_STR("v");
            FX_CALL(_fx_M3AstFM6gen_idRM4id_t2iS(curr_m_idx_0, &slit_209, &temp_id_0, 0), _fx_catch_187);
            FX_CALL(_fx_M3AstFM21default_tempval_flagsRM11val_flags_t0(&flags_2, 0), _fx_catch_187);
            _fx_make_R13Ast__defval_t(&temp_id_0, t1_0, &flags_2, sc_2, &eloc_0, &dv_0);
            _fx_M3AstFM6IdDValN14Ast__id_info_t1RM8defval_t(&dv_0, &v_498);
            FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&temp_id_0, &v_498, 0), _fx_catch_187);
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t1_0, &eloc_0, &v_499);
            FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&temp_id_0, &v_499, &v_500),
               _fx_catch_187);
            FX_CALL(_fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&temp_id_0, &eloc_0, &v_501), _fx_catch_187);
            FX_CALL(
               _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(v_501, e1_8, &flags_2, &eloc_0,
                  &v_502), _fx_catch_187);
            FX_CALL(_fx_cons_LN10Ast__exp_t(v_502, 0, true, &v_503), _fx_catch_187);
            _fx_make_T2N10Ast__exp_tLN10Ast__exp_t(v_500, v_503, &v_495);

         _fx_catch_187: ;
            if (v_503) {
               _fx_free_LN10Ast__exp_t(&v_503);
            }
            if (v_502) {
               _fx_free_N10Ast__exp_t(&v_502);
            }
            if (v_501) {
               _fx_free_N10Ast__pat_t(&v_501);
            }
            if (v_500) {
               _fx_free_N10Ast__exp_t(&v_500);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_499);
            _fx_free_N14Ast__id_info_t(&v_498);
            _fx_free_R13Ast__defval_t(&dv_0);
            _fx_free_R16Ast__val_flags_t(&flags_2);
            goto _fx_endmatch_35;
         }
         _fx_make_T2N10Ast__exp_tLN10Ast__exp_t(e1_8, 0, &v_495);

      _fx_endmatch_35: ;
         FX_CHECK_EXN(_fx_catch_201);
         FX_COPY_PTR(v_495.t0, &e1_9);
         FX_COPY_PTR(v_495.t1, &code_1);
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t1_0, &v_496, 0), _fx_catch_201);
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t2_0, &v_497, 0), _fx_catch_201);
         if (FX_REC_VARIANT_TAG(v_497) == 24) {
            _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_36 = &v_497->u.TypApp;
            if (vcase_36->t0 == 0) {
               if (FX_REC_VARIANT_TAG(v_496) == 24) {
                  _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_37 = &v_496->u.TypApp;
                  if (vcase_37->t0 == 0) {
                     _fx_N10Ast__exp_t new_e1_14 = 0;
                     _fx_N14Ast__id_info_t v_504 = {0};
                     _fx_N14Ast__id_info_t v_505 = {0};
                     _fx_R9Ast__id_t* tn1_0 = &vcase_37->t1;
                     _fx_R9Ast__id_t* tn2_0 = &vcase_36->t1;
                     bool res_40;
                     FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(tn1_0, tn2_0, &res_40, 0), _fx_catch_194);
                     if (res_40) {
                        FX_COPY_PTR(e1_9, &new_e1_14);
                     }
                     else {
                        FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(tn1_0, &eloc_0, &v_504, 0), _fx_catch_194);
                        FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(tn2_0, &eloc_0, &v_505, 0), _fx_catch_194);
                        if (v_504.tag == 6) {
                           if (v_505.tag == 6) {
                              fx_str_t v_506 = {0};
                              fx_str_t v_507 = {0};
                              fx_str_t v_508 = {0};
                              fx_str_t v_509 = {0};
                              fx_str_t v_510 = {0};
                              fx_exn_t v_511 = {0};
                              FX_CALL(_fx_M3AstFM2ppS1RM4id_t(tn1_0, &v_506, 0), _fx_catch_188);
                              FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_506, &v_507, 0), _fx_catch_188);
                              FX_CALL(_fx_M3AstFM2ppS1RM4id_t(tn2_0, &v_508, 0), _fx_catch_188);
                              FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_508, &v_509, 0), _fx_catch_188);
                              fx_str_t slit_210 = FX_MAKE_STR("variant/record type \'");
                              fx_str_t slit_211 = FX_MAKE_STR("\' cannot be casted to another variant/record type \'");
                              fx_str_t slit_212 = FX_MAKE_STR("\'; define a custom function to do the conversion and call it");
                              {
                                 const fx_str_t strs_28[] = { slit_210, v_507, slit_211, v_509, slit_212 };
                                 FX_CALL(fx_strjoin(0, 0, 0, strs_28, 5, &v_510), _fx_catch_188);
                              }
                              FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_510, &v_511, 0), _fx_catch_188);
                              FX_THROW(&v_511, false, _fx_catch_188);

                           _fx_catch_188: ;
                              fx_free_exn(&v_511);
                              FX_FREE_STR(&v_510);
                              FX_FREE_STR(&v_509);
                              FX_FREE_STR(&v_508);
                              FX_FREE_STR(&v_507);
                              FX_FREE_STR(&v_506);
                              goto _fx_endmatch_36;
                           }
                        }
                        if (v_505.tag == 7) {
                           if (v_504.tag == 6) {
                              _fx_R17Ast__defvariant_t v_512 = {0};
                              _fx_R19Ast__definterface_t v_513 = {0};
                              _fx_LT2R9Ast__id_tLTa2R9Ast__id_t dvar_ifaces_0 = 0;
                              fx_str_t v_514 = {0};
                              fx_str_t v_515 = {0};
                              fx_str_t v_516 = {0};
                              fx_str_t v_517 = {0};
                              fx_str_t v_518 = {0};
                              fx_exn_t v_519 = {0};
                              _fx_LN10Ast__exp_t v_520 = 0;
                              _fx_T2N10Ast__typ_tR10Ast__loc_t v_521 = {0};
                              _fx_copy_R17Ast__defvariant_t(&v_504.u.IdVariant->data, &v_512);
                              _fx_copy_R19Ast__definterface_t(&v_505.u.IdInterface->data, &v_513);
                              _fx_R9Ast__id_t* di_name_0 = &v_513.di_name;
                              bool __fold_result___8 = false;
                              FX_COPY_PTR(v_512.dvar_ifaces, &dvar_ifaces_0);
                              _fx_LT2R9Ast__id_tLTa2R9Ast__id_t lst_24 = dvar_ifaces_0;
                              for (; lst_24; lst_24 = lst_24->tl) {
                                 _fx_T2R9Ast__id_tLTa2R9Ast__id_t* __pat___7 = &lst_24->hd;
                                 _fx_R9Ast__id_t i_2 = __pat___7->t0;
                                 bool v_522;
                                 FX_CALL(
                                    _fx_M3AstFM14same_or_parentB3RM4id_tRM4id_tRM5loc_t(&i_2, di_name_0, &eloc_0, &v_522, 0),
                                    _fx_catch_189);
                                 if (v_522) {
                                    __fold_result___8 = true; FX_BREAK(_fx_catch_189);
                                 }

                              _fx_catch_189: ;
                                 FX_CHECK_BREAK();
                                 FX_CHECK_EXN(_fx_catch_190);
                              }
                              if (!__fold_result___8) {
                                 FX_CALL(_fx_M3AstFM2ppS1RM4id_t(tn1_0, &v_514, 0), _fx_catch_190);
                                 FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_514, &v_515, 0), _fx_catch_190);
                                 FX_CALL(_fx_M3AstFM2ppS1RM4id_t(di_name_0, &v_516, 0), _fx_catch_190);
                                 FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_516, &v_517, 0), _fx_catch_190);
                                 fx_str_t slit_213 = FX_MAKE_STR("variant/record type \'");
                                 fx_str_t slit_214 = FX_MAKE_STR("\' is casted to interface \'");
                                 fx_str_t slit_215 =
                                    FX_MAKE_STR(
                                       "\', but the type does not implement any of the interfaces that can be casted to the interface");
                                 {
                                    const fx_str_t strs_29[] = { slit_213, v_515, slit_214, v_517, slit_215 };
                                    FX_CALL(fx_strjoin(0, 0, 0, strs_29, 5, &v_518), _fx_catch_190);
                                 }
                                 FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_518, &v_519, 0), _fx_catch_190);
                                 FX_THROW(&v_519, false, _fx_catch_190);
                              }
                              FX_CALL(_fx_cons_LN10Ast__exp_t(e1_9, 0, true, &v_520), _fx_catch_190);
                              _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_0, &eloc_0, &v_521);
                              FX_CALL(
                                 _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    &_fx_g31Ast_typecheck__IntrinQueryIface, v_520, &v_521, &new_e1_14), _fx_catch_190);

                           _fx_catch_190: ;
                              _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_521);
                              if (v_520) {
                                 _fx_free_LN10Ast__exp_t(&v_520);
                              }
                              fx_free_exn(&v_519);
                              FX_FREE_STR(&v_518);
                              FX_FREE_STR(&v_517);
                              FX_FREE_STR(&v_516);
                              FX_FREE_STR(&v_515);
                              FX_FREE_STR(&v_514);
                              if (dvar_ifaces_0) {
                                 _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(&dvar_ifaces_0);
                              }
                              _fx_free_R19Ast__definterface_t(&v_513);
                              _fx_free_R17Ast__defvariant_t(&v_512);
                              goto _fx_endmatch_36;
                           }
                        }
                        if (v_505.tag == 6) {
                           if (v_504.tag == 7) {
                              _fx_R19Ast__definterface_t v_523 = {0};
                              _fx_R17Ast__defvariant_t v_524 = {0};
                              _fx_LT2R9Ast__id_tLTa2R9Ast__id_t dvar_ifaces_1 = 0;
                              fx_str_t v_525 = {0};
                              fx_str_t v_526 = {0};
                              fx_str_t v_527 = {0};
                              fx_str_t v_528 = {0};
                              fx_str_t v_529 = {0};
                              fx_str_t v_530 = {0};
                              fx_str_t v_531 = {0};
                              fx_exn_t v_532 = {0};
                              _fx_LN10Ast__exp_t v_533 = 0;
                              _fx_T2N10Ast__typ_tR10Ast__loc_t v_534 = {0};
                              _fx_copy_R19Ast__definterface_t(&v_504.u.IdInterface->data, &v_523);
                              _fx_R9Ast__id_t* di_name_1 = &v_523.di_name;
                              _fx_copy_R17Ast__defvariant_t(&v_505.u.IdVariant->data, &v_524);
                              bool __fold_result___9 = false;
                              FX_COPY_PTR(v_524.dvar_ifaces, &dvar_ifaces_1);
                              _fx_LT2R9Ast__id_tLTa2R9Ast__id_t lst_25 = dvar_ifaces_1;
                              for (; lst_25; lst_25 = lst_25->tl) {
                                 _fx_T2R9Ast__id_tLTa2R9Ast__id_t* __pat___8 = &lst_25->hd;
                                 _fx_R9Ast__id_t i_3 = __pat___8->t0;
                                 bool v_535;
                                 FX_CALL(
                                    _fx_M3AstFM14same_or_parentB3RM4id_tRM4id_tRM5loc_t(&i_3, di_name_1, &eloc_0, &v_535, 0),
                                    _fx_catch_191);
                                 if (v_535) {
                                    __fold_result___9 = true; FX_BREAK(_fx_catch_191);
                                 }

                              _fx_catch_191: ;
                                 FX_CHECK_BREAK();
                                 FX_CHECK_EXN(_fx_catch_192);
                              }
                              if (!__fold_result___9) {
                                 FX_CALL(_fx_M3AstFM2ppS1RM4id_t(di_name_1, &v_525, 0), _fx_catch_192);
                                 FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_525, &v_526, 0), _fx_catch_192);
                                 FX_CALL(_fx_M3AstFM2ppS1RM4id_t(tn1_0, &v_527, 0), _fx_catch_192);
                                 FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_527, &v_528, 0), _fx_catch_192);
                                 FX_CALL(_fx_M3AstFM2ppS1RM4id_t(di_name_1, &v_529, 0), _fx_catch_192);
                                 FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_529, &v_530, 0), _fx_catch_192);
                                 fx_str_t slit_216 = FX_MAKE_STR("interface \'");
                                 fx_str_t slit_217 = FX_MAKE_STR("\' is casted to variant/record type \'");
                                 fx_str_t slit_218 = FX_MAKE_STR("\', but the type does not implement neither \'");
                                 fx_str_t slit_219 = FX_MAKE_STR("\' nor anything derived from it");
                                 {
                                    const fx_str_t strs_30[] = { slit_216, v_526, slit_217, v_528, slit_218, v_530, slit_219 };
                                    FX_CALL(fx_strjoin(0, 0, 0, strs_30, 7, &v_531), _fx_catch_192);
                                 }
                                 FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_531, &v_532, 0), _fx_catch_192);
                                 FX_THROW(&v_532, false, _fx_catch_192);
                              }
                              FX_CALL(_fx_cons_LN10Ast__exp_t(e1_9, 0, true, &v_533), _fx_catch_192);
                              _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_0, &eloc_0, &v_534);
                              FX_CALL(
                                 _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    &_fx_g30Ast_typecheck__IntrinGetObject, v_533, &v_534, &new_e1_14), _fx_catch_192);

                           _fx_catch_192: ;
                              _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_534);
                              if (v_533) {
                                 _fx_free_LN10Ast__exp_t(&v_533);
                              }
                              fx_free_exn(&v_532);
                              FX_FREE_STR(&v_531);
                              FX_FREE_STR(&v_530);
                              FX_FREE_STR(&v_529);
                              FX_FREE_STR(&v_528);
                              FX_FREE_STR(&v_527);
                              FX_FREE_STR(&v_526);
                              FX_FREE_STR(&v_525);
                              if (dvar_ifaces_1) {
                                 _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(&dvar_ifaces_1);
                              }
                              _fx_free_R17Ast__defvariant_t(&v_524);
                              _fx_free_R19Ast__definterface_t(&v_523);
                              goto _fx_endmatch_36;
                           }
                        }
                        if (v_504.tag == 7) {
                           if (v_505.tag == 7) {
                              _fx_LN10Ast__exp_t v_536 = 0;
                              _fx_T2N10Ast__typ_tR10Ast__loc_t v_537 = {0};
                              FX_CALL(_fx_cons_LN10Ast__exp_t(e1_9, 0, true, &v_536), _fx_catch_193);
                              _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_0, &eloc_0, &v_537);
                              FX_CALL(
                                 _fx_M3AstFM9ExpIntrinN10Ast__exp_t3N13Ast__intrin_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                    &_fx_g31Ast_typecheck__IntrinQueryIface, v_536, &v_537, &new_e1_14), _fx_catch_193);

                           _fx_catch_193: ;
                              _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_537);
                              if (v_536) {
                                 _fx_free_LN10Ast__exp_t(&v_536);
                              }
                              goto _fx_endmatch_36;
                           }
                        }
                        FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_194);

                     _fx_endmatch_36: ;
                        FX_CHECK_EXN(_fx_catch_194);
                     }
                     fx_str_t slit_220 =
                        FX_MAKE_STR("the output type of cast operation \'{t2}\' does not match the expected type \'{etyp}\'");
                     FX_CALL(
                        _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t2_0, etyp_0, &eloc_0, &slit_220,
                           0), _fx_catch_194);
                     _fx_free_N10Ast__exp_t(&result_0);
                     FX_COPY_PTR(new_e1_14, &result_0);
                     FX_BREAK(_fx_catch_194);

                  _fx_catch_194: ;
                     _fx_free_N14Ast__id_info_t(&v_505);
                     _fx_free_N14Ast__id_info_t(&v_504);
                     if (new_e1_14) {
                        _fx_free_N10Ast__exp_t(&new_e1_14);
                     }
                     goto _fx_endmatch_38;
                  }
               }
            }
         }
         _fx_N10Ast__typ_t v_538 = 0;
         _fx_N10Ast__typ_t v_539 = 0;
         fx_str_t v_540 = {0};
         fx_str_t v_541 = {0};
         fx_str_t v_542 = {0};
         fx_str_t v_543 = {0};
         fx_str_t v_544 = {0};
         fx_exn_t v_545 = {0};
         _fx_N10Ast__exp_t result_53 = 0;
         fx_exn_t exn_3 = {0};
         bool v_546;
         FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(t1_0, &v_546, 0), _fx_catch_200);
         bool v_547;
         bool t_18;
         if (!v_546) {
            bool v_548; FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(t2_0, &v_548, 0), _fx_catch_200); t_18 = !v_548;
         }
         else {
            t_18 = false;
         }
         if (t_18) {
            FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t1_0, &v_538, 0), _fx_catch_200);
            FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t2_0, &v_539, 0), _fx_catch_200);
            if (FX_REC_VARIANT_TAG(v_538) == 17) {
               if (FX_REC_VARIANT_TAG(v_539) == 17) {
                  v_547 = false; goto _fx_endmatch_37;
               }
            }
            v_547 = true;

         _fx_endmatch_37: ;
            FX_CHECK_EXN(_fx_catch_200);
         }
         else {
            v_547 = false;
         }
         if (v_547) {
            FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t1_0, &v_540, 0), _fx_catch_200);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_540, &v_541, 0), _fx_catch_200);
            FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t2_0, &v_542, 0), _fx_catch_200);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_542, &v_543, 0), _fx_catch_200);
            fx_str_t slit_221 = FX_MAKE_STR("invalid cast operation: \'");
            fx_str_t slit_222 = FX_MAKE_STR("\' to \'");
            fx_str_t slit_223 = FX_MAKE_STR("\'");
            {
               const fx_str_t strs_31[] = { slit_221, v_541, slit_222, v_543, slit_223 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_31, 5, &v_544), _fx_catch_200);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_544, &v_545, 0), _fx_catch_200);
            FX_THROW(&v_545, false, _fx_catch_200);
         }
         _fx_N10Ast__exp_t e2_4 = 0;
         _fx_N10Ast__typ_t t2_1 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM9make_castN10Ast__exp_t4N10Ast__exp_tN10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(e1_9, t1_0, t2_0,
               &eloc_0, &e2_4, 0), _fx_catch_196);
         FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(e2_4, &t2_1, 0), _fx_catch_196);
         fx_str_t slit_224 = FX_MAKE_STR("unexpected type of cast operation");
         FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, t2_1, &eloc_0, &slit_224, 0),
            _fx_catch_196);
         if (code_1 != 0) {
            _fx_LN10Ast__exp_t v_549 = 0;
            _fx_LN10Ast__exp_t v_550 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_551 = {0};
            FX_CALL(_fx_cons_LN10Ast__exp_t(e2_4, 0, true, &v_549), _fx_catch_195);
            FX_CALL(_fx_M13Ast_typecheckFM7__add__LN10Ast__exp_t2LN10Ast__exp_tLN10Ast__exp_t(code_1, v_549, &v_550, 0),
               _fx_catch_195);
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_1, &eloc_0, &v_551);
            FX_CALL(_fx_M3AstFM6ExpSeqN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_550, &v_551, &result_53),
               _fx_catch_195);

         _fx_catch_195: ;
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_551);
            if (v_550) {
               _fx_free_LN10Ast__exp_t(&v_550);
            }
            if (v_549) {
               _fx_free_LN10Ast__exp_t(&v_549);
            }
         }
         else {
            FX_COPY_PTR(e2_4, &result_53);
         }
         FX_CHECK_EXN(_fx_catch_196);

      _fx_catch_196: ;
         if (e2_4) {
            _fx_free_N10Ast__exp_t(&e2_4);
         }
         if (t2_1) {
            _fx_free_N10Ast__typ_t(&t2_1);
         }
         if (fx_status < 0) {
            fx_exn_get_and_reset(fx_status, &exn_3);
            fx_status = 0;
            if (result_53) {
               _fx_free_N10Ast__exp_t(&result_53);
            }
            if (exn_3.tag == _FX_EXN_E17Ast__CompileError) {
               fx_exn_t exn_4 = {0};
               _fx_LN10Ast__exp_t v_552 = 0;
               _fx_R9Ast__id_t fname_0;
               FX_CALL(_fx_M3AstFM14get_cast_fnameRM4id_t2N10Ast__typ_tRM5loc_t(t2_0, &eloc_0, &fname_0, 0), _fx_catch_197);
               FX_CALL(_fx_cons_LN10Ast__exp_t(e1_9, 0, true, &v_552), _fx_catch_197);
               FX_CALL(
                  _fx_M13Ast_typecheckFM19check_and_make_callN10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
                     &fname_0, v_552, &ctx_0, &eloc_0, &env_2, etyp_0, sc_2, &result_53, 0), _fx_catch_197);

            _fx_catch_197: ;
               if (v_552) {
                  _fx_free_LN10Ast__exp_t(&v_552);
               }
               if (fx_status < 0) {
                  fx_exn_get_and_reset(fx_status, &exn_4);
                  fx_status = 0;
                  if (result_53) {
                     _fx_free_N10Ast__exp_t(&result_53);
                  }
                  if (exn_4.tag == _FX_EXN_E17Ast__CompileError) {
                     fx_str_t v_553 = {0};
                     fx_str_t v_554 = {0};
                     fx_str_t v_555 = {0};
                     fx_str_t v_556 = {0};
                     fx_str_t v_557 = {0};
                     fx_exn_t v_558 = {0};
                     FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t1_0, &v_553, 0), _fx_catch_198);
                     FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_553, &v_554, 0), _fx_catch_198);
                     FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t2_0, &v_555, 0), _fx_catch_198);
                     FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_555, &v_556, 0), _fx_catch_198);
                     fx_str_t slit_225 = FX_MAKE_STR("invalid cast operation: \'");
                     fx_str_t slit_226 = FX_MAKE_STR("\' to \'");
                     fx_str_t slit_227 = FX_MAKE_STR("\'");
                     {
                        const fx_str_t strs_32[] = { slit_225, v_554, slit_226, v_556, slit_227 };
                        FX_CALL(fx_strjoin(0, 0, 0, strs_32, 5, &v_557), _fx_catch_198);
                     }
                     FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &v_557, &v_558, 0), _fx_catch_198);
                     FX_THROW(&v_558, false, _fx_catch_198);

                  _fx_catch_198: ;
                     fx_free_exn(&v_558);
                     FX_FREE_STR(&v_557);
                     FX_FREE_STR(&v_556);
                     FX_FREE_STR(&v_555);
                     FX_FREE_STR(&v_554);
                     FX_FREE_STR(&v_553);
                  }
                  else {
                     FX_RETHROW(&exn_4, _fx_catch_199);
                  }
                  FX_CHECK_EXN(_fx_catch_199);
               }

            _fx_catch_199: ;
               fx_free_exn(&exn_4);
            }
            else {
               FX_RETHROW(&exn_3, _fx_catch_200);
            }
            FX_CHECK_EXN(_fx_catch_200);
         }
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_53, &result_0);
         FX_BREAK(_fx_catch_200);

      _fx_catch_200: ;
         fx_free_exn(&exn_3);
         if (result_53) {
            _fx_free_N10Ast__exp_t(&result_53);
         }
         fx_free_exn(&v_545);
         FX_FREE_STR(&v_544);
         FX_FREE_STR(&v_543);
         FX_FREE_STR(&v_542);
         FX_FREE_STR(&v_541);
         FX_FREE_STR(&v_540);
         if (v_539) {
            _fx_free_N10Ast__typ_t(&v_539);
         }
         if (v_538) {
            _fx_free_N10Ast__typ_t(&v_538);
         }

      _fx_endmatch_38: ;
         FX_CHECK_EXN(_fx_catch_201);

      _fx_catch_201: ;
         if (v_497) {
            _fx_free_N10Ast__typ_t(&v_497);
         }
         if (v_496) {
            _fx_free_N10Ast__typ_t(&v_496);
         }
         if (code_1) {
            _fx_free_LN10Ast__exp_t(&code_1);
         }
         if (e1_9) {
            _fx_free_N10Ast__exp_t(&e1_9);
         }
         _fx_free_T2N10Ast__exp_tLN10Ast__exp_t(&v_495);
         if (v_494) {
            _fx_free_N10Ast__typ_t(&v_494);
         }
         if (v_493) {
            _fx_free_N10Ast__typ_t(&v_493);
         }
         if (t1_0) {
            _fx_free_N10Ast__typ_t(&t1_0);
         }
         if (e1_8) {
            _fx_free_N10Ast__exp_t(&e1_8);
         }
         if (t2_0) {
            _fx_free_N10Ast__typ_t(&t2_0);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 31) {
         _fx_N10Ast__typ_t new_t1_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_559 = {0};
         _fx_N10Ast__typ_t e1typ_1 = 0;
         _fx_N10Ast__exp_t new_e1_15 = 0;
         _fx_N10Ast__exp_t result_54 = 0;
         _fx_T3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tR10Ast__loc_t* vcase_38 = &e_2->u.ExpTyped;
         _fx_N10Ast__exp_t e1_10 = vcase_38->t0;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               vcase_38->t1, &env_2, sc_2, &eloc_0, &new_t1_0, 0), _fx_catch_202);
         FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_10, &v_559, 0), _fx_catch_202);
         FX_COPY_PTR(v_559.t0, &e1typ_1);
         _fx_R10Ast__loc_t e1loc_1 = v_559.t1;
         fx_str_t slit_228 = FX_MAKE_STR("improper explicit type of the expression");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, new_t1_0, &eloc_0, &slit_228, 0),
            _fx_catch_202);
         fx_str_t slit_229 = FX_MAKE_STR("improper explicit type of the expression");
         FX_CALL(
            _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(e1typ_1, new_t1_0, &e1loc_1, &slit_229, 0),
            _fx_catch_202);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e1_10, &env_2, sc_2, &new_e1_15, 0), _fx_catch_202);
         FX_CALL(
            _fx_M3AstFM8ExpTypedN10Ast__exp_t3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tRM5loc_t(new_e1_15, new_t1_0, &ctx_0,
               &result_54), _fx_catch_202);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_54, &result_0);
         FX_BREAK(_fx_catch_202);

      _fx_catch_202: ;
         if (result_54) {
            _fx_free_N10Ast__exp_t(&result_54);
         }
         if (new_e1_15) {
            _fx_free_N10Ast__exp_t(&new_e1_15);
         }
         if (e1typ_1) {
            _fx_free_N10Ast__typ_t(&e1typ_1);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_559);
         if (new_t1_0) {
            _fx_free_N10Ast__typ_t(&new_t1_0);
         }
         goto _fx_endmatch_41;
      }
      if (tag_0 == 32) {
         if (sc_2 != 0) {
            if (sc_2->hd.tag == 10) {
               _fx_free_N10Ast__exp_t(&result_0);
               FX_COPY_PTR(e_2, &result_0);
               FX_BREAK(_fx_catch_203);

            _fx_catch_203: ;
               goto _fx_endmatch_39;
            }
         }
         fx_str_t str_0 = {0};
         fx_str_t str_1 = {0};
         _fx_N10Ast__exp_t result_55 = 0;
         FX_CALL(_fx_M6StringFM5stripS1S(&e_2->u.ExpCCode.t0, &str_0, 0), _fx_catch_204);
         bool v_560;
         if (_fx_M6StringFM8endswithB2SC(&str_0, (char_)125, 0)) {
            v_560 = true;
         }
         else {
            v_560 = _fx_M6StringFM8endswithB2SC(&str_0, (char_)59, 0);
         }
         if (v_560) {
            fx_copy_str(&str_0, &str_1);
         }
         else {
            const fx_str_t strs_33[] = { str_0, FX_MAKE_STR1(";") };
            FX_CALL(fx_strjoin(0, 0, 0, strs_33, 2, &str_1), _fx_catch_204);
         }
         FX_CALL(_fx_M3AstFM8ExpCCodeN10Ast__exp_t2ST2N10Ast__typ_tRM5loc_t(&str_1, &ctx_0, &result_55), _fx_catch_204);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_55, &result_0);
         FX_BREAK(_fx_catch_204);

      _fx_catch_204: ;
         if (result_55) {
            _fx_free_N10Ast__exp_t(&result_55);
         }
         FX_FREE_STR(&str_1);
         FX_FREE_STR(&str_0);

      _fx_endmatch_39: ;
         FX_CHECK_EXN(_fx_catch_205);

      _fx_catch_205: ;
         goto _fx_endmatch_41;
      }
      if (tag_0 == 33) {
         _fx_N10Ast__typ_t t_19 = 0;
         _fx_N10Ast__typ_t v_561 = 0;
         _fx_Nt6option1N10Ast__typ_t v_562 = 0;
         _fx_N10Ast__exp_t result_56 = 0;
         _fx_T3SST2N10Ast__typ_tR10Ast__loc_t* vcase_39 = &e_2->u.ExpData;
         fx_str_t* kind_0 = &vcase_39->t0;
         bool v_563;
         fx_str_t slit_230 = FX_MAKE_STR("text");
         v_563 = _fx_F6__eq__B2SS(kind_0, &slit_230, 0);
         if (v_563) {
            FX_COPY_PTR(_fx_g24Ast_typecheck__TypString, &t_19);
         }
         else {
            FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp_0, &v_561, 0), _fx_catch_208);
            if (FX_REC_VARIANT_TAG(v_561) == 1) {
               FX_COPY_PTR(v_561->u.TypVar->data, &v_562);
               if ((v_562 != 0) + 1 == 1) {
                  _fx_N10Ast__typ_t v_564 = 0;
                  FX_CALL(_fx_M3AstFM7TypUIntN10Ast__typ_t1i(8, &v_564), _fx_catch_206);
                  FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(1, v_564, &t_19), _fx_catch_206);

               _fx_catch_206: ;
                  if (v_564) {
                     _fx_free_N10Ast__typ_t(&v_564);
                  }
                  goto _fx_endmatch_40;
               }
            }
            _fx_N10Ast__typ_t v_565 = 0;
            FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_565, 0), _fx_catch_207);
            FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(1, v_565, &t_19), _fx_catch_207);

         _fx_catch_207: ;
            if (v_565) {
               _fx_free_N10Ast__typ_t(&v_565);
            }

         _fx_endmatch_40: ;
            FX_CHECK_EXN(_fx_catch_208);
         }
         fx_str_t slit_231 =
            FX_MAKE_STR("the output type of @data/@text \'{typ2str(t)}\' does not match the expected one \'{typ2str(etyp)}\'");
         FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, t_19, &eloc_0, &slit_231, 0),
            _fx_catch_208);
         FX_CALL(_fx_M3AstFM7ExpDataN10Ast__exp_t3SST2N10Ast__typ_tRM5loc_t(kind_0, &vcase_39->t1, &ctx_0, &result_56),
            _fx_catch_208);
         _fx_free_N10Ast__exp_t(&result_0);
         FX_COPY_PTR(result_56, &result_0);
         FX_BREAK(_fx_catch_208);

      _fx_catch_208: ;
         if (result_56) {
            _fx_free_N10Ast__exp_t(&result_56);
         }
         if (v_562) {
            _fx_free_Nt6option1N10Ast__typ_t(&v_562);
         }
         if (v_561) {
            _fx_free_N10Ast__typ_t(&v_561);
         }
         if (t_19) {
            _fx_free_N10Ast__typ_t(&t_19);
         }
         goto _fx_endmatch_41;
      }
      bool res_41;
      if (tag_0 == 34) {
         res_41 = true;
      }
      else if (tag_0 == 35) {
         res_41 = true;
      }
      else if (tag_0 == 38) {
         res_41 = true;
      }
      else if (tag_0 == 39) {
         res_41 = true;
      }
      else if (tag_0 == 36) {
         res_41 = true;
      }
      else if (tag_0 == 37) {
         res_41 = true;
      }
      else if (tag_0 == 40) {
         res_41 = true;
      }
      else if (tag_0 == 41) {
         res_41 = true;
      }
      else if (tag_0 == 42) {
         res_41 = true;
      }
      else {
         res_41 = false;
      }
      FX_CHECK_EXN(_fx_catch_210);
      if (res_41) {
         fx_exn_t v_566 = {0};
         fx_str_t slit_232 =
            FX_MAKE_STR("internal err: should not get here; all the declarations and directives must be handled in check_eseq");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_232, &v_566, 0), _fx_catch_209);
         FX_THROW(&v_566, false, _fx_catch_209);

      _fx_catch_209: ;
         fx_free_exn(&v_566);
         goto _fx_endmatch_41;
      }
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_210);

   _fx_endmatch_41: ;
      FX_CHECK_EXN(_fx_catch_210);

   _fx_catch_210: ;
      if (etyp_0) {
         _fx_free_N10Ast__typ_t(&etyp_0);
      }
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&ctx_0);
      FX_FREE_LIST_SIMPLE(&sc_2);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
      if (e_2) {
         _fx_free_N10Ast__exp_t(&e_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(result_0, fx_result);

_fx_cleanup: ;
   if (result_0) {
      _fx_free_N10Ast__exp_t(&result_0);
   }
   if (e_1) {
      _fx_free_N10Ast__exp_t(&e_1);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   FX_FREE_LIST_SIMPLE(&sc_1);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM16check_for_clauseT6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t7N10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tR16Ast__for_flags_tLN12Ast__scope_ti(
   struct _fx_N10Ast__pat_t_data_t* p_0,
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Set__t1R9Ast__id_t* idset_0,
   struct _fx_R16Ast__for_flags_t* flags_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   int_ curr_m_idx_0,
   struct _fx_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      fx_result,
   void* fx_fv)
{
   _fx_N10Ast__exp_t e_1 = 0;
   _fx_T2N10Ast__typ_tR10Ast__loc_t v_0 = {0};
   _fx_N10Ast__typ_t etyp_0 = 0;
   _fx_N10Ast__typ_t etyp_1 = 0;
   _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_1 = {0};
   _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_0 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(e_0,
         env_0, sc_0, &e_1, 0), _fx_cleanup);
   bool is_range_0;
   if (FX_REC_VARIANT_TAG(e_1) == 5) {
      is_range_0 = true;
   }
   else {
      is_range_0 = false;
   }
   FX_CHECK_EXN(_fx_cleanup);
   FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e_1, &v_0, 0), _fx_cleanup);
   FX_COPY_PTR(v_0.t0, &etyp_0);
   _fx_R10Ast__loc_t eloc_0 = v_0.t1;
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp_0, &etyp_1, 0), _fx_cleanup);
   if (FX_REC_VARIANT_TAG(etyp_1) == 24) {
      fx_exn_t exn_0 = {0};
      FX_CALL(
         _fx_M13Ast_typecheckFM16get_record_elemsT2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t4Nt6option1R9Ast__id_tN10Ast__typ_tBR10Ast__loc_t(
            &_fx_g21Ast_typecheck__None9_, etyp_1, false, &eloc_0, &v_1, 0), _fx_catch_0);

   _fx_catch_0: ;
      if (fx_status < 0) {
         fx_exn_get_and_reset(fx_status, &exn_0);
         fx_status = 0;
         _fx_free_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_1);
         if (exn_0.tag == _FX_EXN_E17Ast__CompileError) {
            _fx_make_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&_fx_g9Ast__noid, 0, &v_1);
         }
         else {
            FX_RETHROW(&exn_0, _fx_catch_1);
         }
         FX_CHECK_EXN(_fx_catch_1);
      }

   _fx_catch_1: ;
      fx_free_exn(&exn_0);
   }
   else {
      _fx_make_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&_fx_g9Ast__noid, 0, &v_1);
   }
   FX_CHECK_EXN(_fx_cleanup);
   FX_COPY_PTR(v_1.t1, &relems_0);
   if (is_range_0 == false) {
      if (FX_REC_VARIANT_TAG(etyp_1) == 17) {
         _fx_N10Ast__pat_t tup_pat_0 = 0;
         _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_2 = {0};
         _fx_N10Ast__pat_t tup_pat_1 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
         _fx_Rt6Set__t1R9Ast__id_t idset_1 = {0};
         _fx_R16Ast__val_flags_t v_3 = {0};
         _fx_N10Ast__exp_t def_e_0 = 0;
         _fx_N10Ast__exp_t tup_e_0 = 0;
         _fx_T2N10Ast__pat_tN10Ast__exp_t v_4 = {0};
         _fx_LN10Ast__exp_t v_5 = 0;
         _fx_R9Ast__id_t v_6;
         fx_str_t slit_0 = FX_MAKE_STR("tup");
         FX_CALL(_fx_M3AstFM6gen_idRM4id_t2iS(curr_m_idx_0, &slit_0, &v_6, 0), _fx_catch_5);
         FX_CALL(_fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&v_6, &eloc_0, &tup_pat_0), _fx_catch_5);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
               tup_pat_0, etyp_1, env_0, idset_0, &_fx_g16Ast__empty_idset, sc_0, false, true, false, &v_2, 0), _fx_catch_5);
         FX_COPY_PTR(v_2.t0, &tup_pat_1);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_2.t1, &env_1);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_2.t2, &idset_1);
         FX_CALL(_fx_M3AstFM21default_tempval_flagsRM11val_flags_t0(&v_3, 0), _fx_catch_5);
         FX_CALL(
            _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(tup_pat_1, e_1, &v_3, &eloc_0,
               &def_e_0), _fx_catch_5);
         int tag_0 = FX_REC_VARIANT_TAG(tup_pat_1);
         if (tag_0 == 3) {
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_7 = {0};
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(etyp_1, &eloc_0, &v_7);
            FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&tup_pat_1->u.PatIdent.t0, &v_7, &tup_e_0),
               _fx_catch_2);

         _fx_catch_2: ;
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_7);
            goto _fx_endmatch_0;
         }
         if (tag_0 == 9) {
            _fx_N10Ast__pat_t v_8 = tup_pat_1->u.PatTyped.t0;
            if (FX_REC_VARIANT_TAG(v_8) == 3) {
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_9 = {0};
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(etyp_1, &eloc_0, &v_9);
               FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&v_8->u.PatIdent.t0, &v_9, &tup_e_0),
                  _fx_catch_3);

            _fx_catch_3: ;
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_9);
               goto _fx_endmatch_0;
            }
         }
         fx_exn_t v_10 = {0};
         fx_str_t slit_1 =
            FX_MAKE_STR("for over tuple: invalid result of\n"
               U"                                     check_pat result (id is expected)");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_1, &v_10, 0), _fx_catch_4);
         FX_THROW(&v_10, false, _fx_catch_4);

      _fx_catch_4: ;
         fx_free_exn(&v_10);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_5);
         int_ v_11 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(etyp_1->u.TypTuple, 0);
         _fx_make_T2N10Ast__pat_tN10Ast__exp_t(p_0, tup_e_0, &v_4);
         FX_CALL(_fx_cons_LN10Ast__exp_t(def_e_0, 0, true, &v_5), _fx_catch_5);
         _fx_make_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
            v_11, &v_4, v_5, 1, &env_1, &idset_1, fx_result);

      _fx_catch_5: ;
         if (v_5) {
            _fx_free_LN10Ast__exp_t(&v_5);
         }
         _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&v_4);
         if (tup_e_0) {
            _fx_free_N10Ast__exp_t(&tup_e_0);
         }
         if (def_e_0) {
            _fx_free_N10Ast__exp_t(&def_e_0);
         }
         _fx_free_R16Ast__val_flags_t(&v_3);
         _fx_free_Rt6Set__t1R9Ast__id_t(&idset_1);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
         if (tup_pat_1) {
            _fx_free_N10Ast__pat_t(&tup_pat_1);
         }
         _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_2);
         if (tup_pat_0) {
            _fx_free_N10Ast__pat_t(&tup_pat_0);
         }
         goto _fx_endmatch_2;
      }
   }
   if (is_range_0 == false) {
      if (relems_0 != 0) {
         _fx_N10Ast__pat_t rec_pat_0 = 0;
         _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_12 = {0};
         _fx_N10Ast__pat_t rec_pat_1 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
         _fx_Rt6Set__t1R9Ast__id_t idset_2 = {0};
         _fx_R16Ast__val_flags_t v_13 = {0};
         _fx_N10Ast__exp_t def_e_1 = 0;
         _fx_N10Ast__exp_t rec_e_0 = 0;
         _fx_T2N10Ast__pat_tN10Ast__exp_t v_14 = {0};
         _fx_LN10Ast__exp_t v_15 = 0;
         _fx_R9Ast__id_t v_16;
         fx_str_t slit_2 = FX_MAKE_STR("rec");
         FX_CALL(_fx_M3AstFM6gen_idRM4id_t2iS(curr_m_idx_0, &slit_2, &v_16, 0), _fx_catch_9);
         FX_CALL(_fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&v_16, &eloc_0, &rec_pat_0), _fx_catch_9);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
               rec_pat_0, etyp_1, env_0, idset_0, &_fx_g16Ast__empty_idset, sc_0, false, true, false, &v_12, 0), _fx_catch_9);
         FX_COPY_PTR(v_12.t0, &rec_pat_1);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_12.t1, &env_2);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_12.t2, &idset_2);
         FX_CALL(_fx_M3AstFM21default_tempval_flagsRM11val_flags_t0(&v_13, 0), _fx_catch_9);
         FX_CALL(
            _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(rec_pat_1, e_1, &v_13, &eloc_0,
               &def_e_1), _fx_catch_9);
         int tag_1 = FX_REC_VARIANT_TAG(rec_pat_1);
         if (tag_1 == 3) {
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_17 = {0};
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(etyp_1, &eloc_0, &v_17);
            FX_CALL(
               _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&rec_pat_1->u.PatIdent.t0, &v_17, &rec_e_0),
               _fx_catch_6);

         _fx_catch_6: ;
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_17);
            goto _fx_endmatch_1;
         }
         if (tag_1 == 9) {
            _fx_N10Ast__pat_t v_18 = rec_pat_1->u.PatTyped.t0;
            if (FX_REC_VARIANT_TAG(v_18) == 3) {
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_19 = {0};
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(etyp_1, &eloc_0, &v_19);
               FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&v_18->u.PatIdent.t0, &v_19, &rec_e_0),
                  _fx_catch_7);

            _fx_catch_7: ;
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_19);
               goto _fx_endmatch_1;
            }
         }
         fx_exn_t v_20 = {0};
         fx_str_t slit_3 = FX_MAKE_STR("for over record: invalid result of check_pat result (id is expected)");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_3, &v_20, 0), _fx_catch_8);
         FX_THROW(&v_20, false, _fx_catch_8);

      _fx_catch_8: ;
         fx_free_exn(&v_20);

      _fx_endmatch_1: ;
         FX_CHECK_EXN(_fx_catch_9);
         int_ v_21 = _fx_M13Ast_typecheckFM6lengthi1LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(relems_0, 0);
         _fx_make_T2N10Ast__pat_tN10Ast__exp_t(p_0, rec_e_0, &v_14);
         FX_CALL(_fx_cons_LN10Ast__exp_t(def_e_1, 0, true, &v_15), _fx_catch_9);
         _fx_make_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
            v_21, &v_14, v_15, 1, &env_2, &idset_2, fx_result);

      _fx_catch_9: ;
         if (v_15) {
            _fx_free_LN10Ast__exp_t(&v_15);
         }
         _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&v_14);
         if (rec_e_0) {
            _fx_free_N10Ast__exp_t(&rec_e_0);
         }
         if (def_e_1) {
            _fx_free_N10Ast__exp_t(&def_e_1);
         }
         _fx_free_R16Ast__val_flags_t(&v_13);
         _fx_free_Rt6Set__t1R9Ast__id_t(&idset_2);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
         if (rec_pat_1) {
            _fx_free_N10Ast__pat_t(&rec_pat_1);
         }
         _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_12);
         if (rec_pat_0) {
            _fx_free_N10Ast__pat_t(&rec_pat_0);
         }
         goto _fx_endmatch_2;
      }
   }
   _fx_T2N10Ast__typ_ti v_22 = {0};
   _fx_N10Ast__typ_t ptyp_0 = 0;
   _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_23 = {0};
   _fx_N10Ast__pat_t p_1 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
   _fx_Rt6Set__t1R9Ast__id_t idset_3 = {0};
   _fx_T2N10Ast__pat_tN10Ast__exp_t v_24 = {0};
   if (FX_REC_VARIANT_TAG(e_1) == 5) {
      _fx_make_T2N10Ast__typ_ti(_fx_g21Ast_typecheck__TypInt, 1, &v_22);
   }
   else if (FX_REC_VARIANT_TAG(etyp_1) == 19) {
      _fx_T2iN10Ast__typ_t* vcase_0 = &etyp_1->u.TypArray; _fx_make_T2N10Ast__typ_ti(vcase_0->t1, vcase_0->t0, &v_22);
   }
   else if (FX_REC_VARIANT_TAG(etyp_1) == 15) {
      if (flags_0->for_flag_parallel) {
         fx_str_t slit_4 = FX_MAKE_STR("\'@parallel for\' over a list is not supported");
         FX_CALL(_fx_M3AstFM15compile_warningv2RM5loc_tS(&eloc_0, &slit_4, 0), _fx_catch_10);
      }
      _fx_make_T2N10Ast__typ_ti(etyp_1->u.TypList, 1, &v_22);

   _fx_catch_10: ;
   }
   else if (FX_REC_VARIANT_TAG(etyp_1) == 16) {
      _fx_make_T2N10Ast__typ_ti(etyp_1->u.TypVector, 1, &v_22);
   }
   else if (FX_REC_VARIANT_TAG(etyp_1) == 10) {
      _fx_make_T2N10Ast__typ_ti(_fx_g22Ast_typecheck__TypChar, 1, &v_22);
   }
   else {
      fx_exn_t v_25 = {0};
      fx_str_t slit_5 =
         FX_MAKE_STR("unsupported iteration domain; it should be a range, array, list, string, tuple or a record");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_5, &v_25, 0), _fx_catch_11);
      FX_THROW(&v_25, false, _fx_catch_11);

   _fx_catch_11: ;
      fx_free_exn(&v_25);
   }
   FX_CHECK_EXN(_fx_catch_12);
   FX_COPY_PTR(v_22.t0, &ptyp_0);
   int_ dims_0 = v_22.t1;
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
         p_0, ptyp_0, env_0, idset_0, &_fx_g16Ast__empty_idset, sc_0, false, true, false, &v_23, 0), _fx_catch_12);
   FX_COPY_PTR(v_23.t0, &p_1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_23.t1, &env_3);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&v_23.t2, &idset_3);
   _fx_make_T2N10Ast__pat_tN10Ast__exp_t(p_1, e_1, &v_24);
   _fx_make_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(0,
      &v_24, 0, dims_0, &env_3, &idset_3, fx_result);

_fx_catch_12: ;
   _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&v_24);
   _fx_free_Rt6Set__t1R9Ast__id_t(&idset_3);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
   if (p_1) {
      _fx_free_N10Ast__pat_t(&p_1);
   }
   _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_23);
   if (ptyp_0) {
      _fx_free_N10Ast__typ_t(&ptyp_0);
   }
   _fx_free_T2N10Ast__typ_ti(&v_22);

_fx_endmatch_2: ;

_fx_cleanup: ;
   if (e_1) {
      _fx_free_N10Ast__exp_t(&e_1);
   }
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_0);
   if (etyp_0) {
      _fx_free_N10Ast__typ_t(&etyp_0);
   }
   if (etyp_1) {
      _fx_free_N10Ast__typ_t(&etyp_1);
   }
   _fx_free_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_1);
   if (relems_0) {
      _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_0);
   }
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM17check_for_clausesT7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t7LT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tR16Ast__for_flags_tLN12Ast__scope_ti(
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* for_clauses_0,
   struct _fx_N10Ast__pat_t_data_t* idx_pat_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Set__t1R9Ast__id_t* idset_0,
   struct _fx_R16Ast__for_flags_t* flags_0,
   struct _fx_LN12Ast__scope_t_data_t* for_sc_0,
   int_ curr_m_idx_0,
   struct _fx_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t*
      fx_result,
   void* fx_fv)
{
   _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t
      __fold_result___0 = {0};
   _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_0 = {0};
   _fx_LT2N10Ast__pat_tN10Ast__exp_t for_clauses_1 = 0;
   _fx_LN10Ast__exp_t code_0 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   _fx_Rt6Set__t1R9Ast__id_t idset_1 = {0};
   _fx_N10Ast__typ_t idx_typ_0 = 0;
   _fx_LN10Ast__typ_t v_1 = 0;
   _fx_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_2 = {0};
   _fx_N10Ast__pat_t idx_pat_1 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
   _fx_Rt6Set__t1R9Ast__id_t idset_2 = {0};
   _fx_LN10Ast__exp_t __fold_result___1 = 0;
   _fx_LN10Ast__exp_t v_3 = 0;
   _fx_LT2N10Ast__pat_tN10Ast__exp_t __fold_result___2 = 0;
   _fx_LT2N10Ast__pat_tN10Ast__exp_t v_4 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_make_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(0, 0,
      0, 0, env_0, idset_0, &__fold_result___0);
   int_ idx_0 = 0;
   _fx_LT2N10Ast__pat_tN10Ast__exp_t lst_0 = for_clauses_0;
   for (; lst_0; lst_0 = lst_0->tl, idx_0 += 1) {
      _fx_N10Ast__pat_t pi_0 = 0;
      _fx_N10Ast__exp_t ei_0 = 0;
      _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_5 =
         {0};
      _fx_LT2N10Ast__pat_tN10Ast__exp_t for_clauses_2 = 0;
      _fx_LN10Ast__exp_t code_1 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
      _fx_Rt6Set__t1R9Ast__id_t idset_3 = {0};
      _fx_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_6 =
         {0};
      _fx_N10Ast__pat_t pi_1 = 0;
      _fx_N10Ast__exp_t ei_1 = 0;
      _fx_LN10Ast__exp_t code_i_0 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_4 = {0};
      _fx_Rt6Set__t1R9Ast__id_t idset_4 = {0};
      fx_exn_t v_7 = {0};
      fx_str_t v_8 = {0};
      fx_exn_t v_9 = {0};
      _fx_T2N10Ast__pat_tN10Ast__exp_t v_10 = {0};
      _fx_LN10Ast__exp_t v_11 = 0;
      _fx_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_12 =
         {0};
      _fx_T2N10Ast__pat_tN10Ast__exp_t* __pat___0 = &lst_0->hd;
      FX_COPY_PTR(__pat___0->t0, &pi_0);
      FX_COPY_PTR(__pat___0->t1, &ei_0);
      _fx_copy_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
         &__fold_result___0, &v_5);
      int_ trsz_0 = v_5.t0;
      FX_COPY_PTR(v_5.t1, &for_clauses_2);
      FX_COPY_PTR(v_5.t2, &code_1);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_5.t4, &env_3);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_5.t5, &idset_3);
      FX_CALL(
         _fx_M13Ast_typecheckFM16check_for_clauseT6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t7N10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tR16Ast__for_flags_tLN12Ast__scope_ti(
            pi_0, ei_0, &env_3, &idset_3, flags_0, for_sc_0, curr_m_idx_0, &v_6, 0), _fx_catch_2);
      int_ trszj_0 = v_6.t0;
      _fx_T2N10Ast__pat_tN10Ast__exp_t* v_13 = &v_6.t1;
      FX_COPY_PTR(v_13->t0, &pi_1);
      FX_COPY_PTR(v_13->t1, &ei_1);
      FX_COPY_PTR(v_6.t2, &code_i_0);
      int_ dims_i_0 = v_6.t3;
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_6.t4, &env_4);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_6.t5, &idset_4);
      bool t_0;
      if (idx_0 > 0) {
         t_0 = dims_i_0 != v_5.t3;
      }
      else {
         t_0 = false;
      }
      if (t_0) {
         _fx_R10Ast__loc_t v_14;
         FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(ei_1, &v_14, 0), _fx_catch_2);
         fx_str_t slit_0 = FX_MAKE_STR("the dimensionalities of simultaneously iterated containers/ranges do not match");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&v_14, &slit_0, &v_7, 0), _fx_catch_2);
         FX_THROW(&v_7, false, _fx_catch_2);
      }
      bool t_1;
      if (idx_0 > 0) {
         t_1 = trszj_0 != trsz_0;
      }
      else {
         t_1 = false;
      }
      if (t_1) {
         _fx_R10Ast__loc_t v_15;
         FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(ei_1, &v_15, 0), _fx_catch_2);
         bool t_2;
         if (trsz_0 == 0) {
            t_2 = true;
         }
         else {
            t_2 = trszj_0 == 0;
         }
         if (t_2) {
            fx_str_t slit_1 =
               FX_MAKE_STR(
                  "simultaneous iteration over tuples/records and some other containers or ranges is not supported yet");
            fx_copy_str(&slit_1, &v_8);
         }
         else {
            fx_str_t slit_2 = FX_MAKE_STR("cannot iterate over tuples/records of different size"); fx_copy_str(&slit_2, &v_8);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&v_15, &v_8, &v_9, 0), _fx_catch_2);
         FX_THROW(&v_9, false, _fx_catch_2);
      }
      _fx_make_T2N10Ast__pat_tN10Ast__exp_t(pi_1, ei_1, &v_10);
      FX_CALL(_fx_cons_LT2N10Ast__pat_tN10Ast__exp_t(&v_10, for_clauses_2, false, &for_clauses_2), _fx_catch_2);
      if (code_i_0 == 0) {
         FX_COPY_PTR(code_1, &v_11);
      }
      else if (code_1 == 0) {
         FX_COPY_PTR(code_i_0, &v_11);
      }
      else {
         _fx_LN10Ast__exp_t v_16 = 0;
         _fx_LN10Ast__exp_t lstend_0 = 0;
         _fx_LN10Ast__exp_t lst_1 = code_i_0;
         for (; lst_1; lst_1 = lst_1->tl) {
            _fx_N10Ast__exp_t x_0 = lst_1->hd;
            _fx_LN10Ast__exp_t node_0 = 0;
            FX_CALL(_fx_cons_LN10Ast__exp_t(x_0, 0, false, &node_0), _fx_catch_0);
            FX_LIST_APPEND(v_16, lstend_0, node_0);

         _fx_catch_0: ;
            FX_CHECK_EXN(_fx_catch_1);
         }
         _fx_M13Ast_typecheckFM5link2LN10Ast__exp_t2LN10Ast__exp_tLN10Ast__exp_t(v_16, code_1, &v_11, 0);

      _fx_catch_1: ;
         if (v_16) {
            _fx_free_LN10Ast__exp_t(&v_16);
         }
      }
      FX_CHECK_EXN(_fx_catch_2);
      _fx_make_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
         trszj_0, for_clauses_2, v_11, dims_i_0, &env_4, &idset_4, &v_12);
      _fx_free_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
         &__fold_result___0);
      _fx_copy_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
         &v_12, &__fold_result___0);

   _fx_catch_2: ;
      _fx_free_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
         &v_12);
      if (v_11) {
         _fx_free_LN10Ast__exp_t(&v_11);
      }
      _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&v_10);
      fx_free_exn(&v_9);
      FX_FREE_STR(&v_8);
      fx_free_exn(&v_7);
      _fx_free_Rt6Set__t1R9Ast__id_t(&idset_4);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_4);
      if (code_i_0) {
         _fx_free_LN10Ast__exp_t(&code_i_0);
      }
      if (ei_1) {
         _fx_free_N10Ast__exp_t(&ei_1);
      }
      if (pi_1) {
         _fx_free_N10Ast__pat_t(&pi_1);
      }
      _fx_free_T6iT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
         &v_6);
      _fx_free_Rt6Set__t1R9Ast__id_t(&idset_3);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
      if (code_1) {
         _fx_free_LN10Ast__exp_t(&code_1);
      }
      if (for_clauses_2) {
         _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&for_clauses_2);
      }
      _fx_free_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
         &v_5);
      if (ei_0) {
         _fx_free_N10Ast__exp_t(&ei_0);
      }
      if (pi_0) {
         _fx_free_N10Ast__pat_t(&pi_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
      &__fold_result___0, &v_0);
   int_ trsz_1 = v_0.t0;
   FX_COPY_PTR(v_0.t1, &for_clauses_1);
   FX_COPY_PTR(v_0.t2, &code_0);
   int_ dims_0 = v_0.t3;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0.t4, &env_1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&v_0.t5, &idset_1);
   if (dims_0 == 1) {
      FX_COPY_PTR(_fx_g21Ast_typecheck__TypInt, &idx_typ_0);
   }
   else {
      _fx_LN10Ast__typ_t lstend_1 = 0;
      for (int_ __pat___1 = 0; __pat___1 < dims_0; __pat___1++) {
         _fx_LN10Ast__typ_t node_1 = 0;
         FX_CALL(_fx_cons_LN10Ast__typ_t(_fx_g21Ast_typecheck__TypInt, 0, false, &node_1), _fx_catch_3);
         FX_LIST_APPEND(v_1, lstend_1, node_1);

      _fx_catch_3: ;
         FX_CHECK_EXN(_fx_cleanup);
      }
      FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(v_1, &idx_typ_0), _fx_cleanup);
   }
   if (trsz_1 != 0) {
      _fx_make_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(idx_pat_0, &env_1, &idset_1, &v_2);
   }
   else {
      if (FX_REC_VARIANT_TAG(idx_pat_0) == 1) {
         _fx_make_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(idx_pat_0, &env_1, &idset_1,
            &v_2);
      }
      else {
         _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_17 = {0};
         _fx_N10Ast__pat_t idx_pat_2 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_5 = {0};
         _fx_Rt6Set__t1R9Ast__id_t idset_5 = {0};
         _fx_N10Ast__pat_t v_18 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
               idx_pat_0, idx_typ_0, &env_1, &idset_1, &_fx_g16Ast__empty_idset, for_sc_0, false, true, false, &v_17, 0),
            _fx_catch_4);
         FX_COPY_PTR(v_17.t0, &idx_pat_2);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_17.t1, &env_5);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_17.t2, &idset_5);
         _fx_R10Ast__loc_t v_19;
         FX_CALL(_fx_M3AstFM11get_pat_locRM5loc_t1N10Ast__pat_t(idx_pat_2, &v_19, 0), _fx_catch_4);
         FX_CALL(_fx_M3AstFM8PatTypedN10Ast__pat_t3N10Ast__pat_tN10Ast__typ_tRM5loc_t(idx_pat_2, idx_typ_0, &v_19, &v_18),
            _fx_catch_4);
         _fx_make_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(v_18, &env_5, &idset_5, &v_2);

      _fx_catch_4: ;
         if (v_18) {
            _fx_free_N10Ast__pat_t(&v_18);
         }
         _fx_free_Rt6Set__t1R9Ast__id_t(&idset_5);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_5);
         if (idx_pat_2) {
            _fx_free_N10Ast__pat_t(&idx_pat_2);
         }
         _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_17);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(v_2.t0, &idx_pat_1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_2.t1, &env_2);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&v_2.t2, &idset_2);
   _fx_LN10Ast__exp_t lst_2 = code_0;
   for (; lst_2; lst_2 = lst_2->tl) {
      _fx_LN10Ast__exp_t r_0 = 0;
      _fx_N10Ast__exp_t a_0 = lst_2->hd;
      FX_COPY_PTR(__fold_result___1, &r_0);
      FX_CALL(_fx_cons_LN10Ast__exp_t(a_0, r_0, false, &r_0), _fx_catch_5);
      _fx_free_LN10Ast__exp_t(&__fold_result___1);
      FX_COPY_PTR(r_0, &__fold_result___1);

   _fx_catch_5: ;
      if (r_0) {
         _fx_free_LN10Ast__exp_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___1, &v_3);
   _fx_LT2N10Ast__pat_tN10Ast__exp_t lst_3 = for_clauses_1;
   for (; lst_3; lst_3 = lst_3->tl) {
      _fx_LT2N10Ast__pat_tN10Ast__exp_t r_1 = 0;
      _fx_T2N10Ast__pat_tN10Ast__exp_t* a_1 = &lst_3->hd;
      FX_COPY_PTR(__fold_result___2, &r_1);
      FX_CALL(_fx_cons_LT2N10Ast__pat_tN10Ast__exp_t(a_1, r_1, false, &r_1), _fx_catch_6);
      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&__fold_result___2);
      FX_COPY_PTR(r_1, &__fold_result___2);

   _fx_catch_6: ;
      if (r_1) {
         _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&r_1);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___2, &v_4);
   _fx_make_T7iLN10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
      trsz_1, v_3, v_4, idx_pat_1, dims_0, &env_2, &idset_2, fx_result);

_fx_cleanup: ;
   _fx_free_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(
      &__fold_result___0);
   _fx_free_T6iLT2N10Ast__pat_tN10Ast__exp_tLN10Ast__exp_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_0);
   if (for_clauses_1) {
      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&for_clauses_1);
   }
   if (code_0) {
      _fx_free_LN10Ast__exp_t(&code_0);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   _fx_free_Rt6Set__t1R9Ast__id_t(&idset_1);
   if (idx_typ_0) {
      _fx_free_N10Ast__typ_t(&idx_typ_0);
   }
   if (v_1) {
      _fx_free_LN10Ast__typ_t(&v_1);
   }
   _fx_free_T3N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_2);
   if (idx_pat_1) {
      _fx_free_N10Ast__pat_t(&idx_pat_1);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
   _fx_free_Rt6Set__t1R9Ast__id_t(&idset_2);
   if (__fold_result___1) {
      _fx_free_LN10Ast__exp_t(&__fold_result___1);
   }
   if (v_3) {
      _fx_free_LN10Ast__exp_t(&v_3);
   }
   if (__fold_result___2) {
      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&__fold_result___2);
   }
   if (v_4) {
      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&v_4);
   }
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM20gen_for_in_tuprec_itN10Ast__exp_t8iLT2N10Ast__pat_tN10Ast__exp_tN10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tLN12Ast__scope_t(
   int_ idx_0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* for_clauses_0,
   struct _fx_N10Ast__pat_t_data_t* idx_pat_0,
   struct _fx_N10Ast__exp_t_data_t* body_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* for_sc_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LN12Ast__scope_t sc_1 = 0;
   _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t __fold_result___0 = {0};
   _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_0 = {0};
   _fx_LN10Ast__exp_t code_0 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   _fx_Rt6Set__t1R9Ast__id_t idset_0 = {0};
   _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_1 = {0};
   _fx_LN10Ast__exp_t code_1 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
   _fx_N10Ast__exp_t v_2 = 0;
   _fx_N10Ast__exp_t body_1 = 0;
   _fx_T2N10Ast__typ_tR10Ast__loc_t v_3 = {0};
   _fx_N10Ast__typ_t body_typ_0 = 0;
   _fx_LN10Ast__exp_t v_4 = 0;
   _fx_LN10Ast__exp_t __fold_result___1 = 0;
   _fx_LN10Ast__exp_t v_5 = 0;
   _fx_T2N10Ast__typ_tR10Ast__loc_t v_6 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   _fx_N12Ast__scope_t v_7;
   FX_CALL(_fx_M3AstFM15new_block_scopeN12Ast__scope_t1i(curr_m_idx_0, &v_7, 0), _fx_cleanup);
   FX_CALL(_fx_cons_LN12Ast__scope_t(&v_7, for_sc_0, true, &sc_1), _fx_cleanup);
   _fx_make_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(0, env_0, &_fx_g16Ast__empty_idset,
      &__fold_result___0);
   int_ j_0 = 0;
   _fx_LT2N10Ast__pat_tN10Ast__exp_t lst_0 = for_clauses_0;
   for (; lst_0; lst_0 = lst_0->tl, j_0 += 1) {
      _fx_N10Ast__pat_t pj_0 = 0;
      _fx_N10Ast__exp_t trj_0 = 0;
      _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_8 = {0};
      _fx_LN10Ast__exp_t code_2 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
      _fx_Rt6Set__t1R9Ast__id_t idset_1 = {0};
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_9 = {0};
      _fx_N10Ast__typ_t ttrj_0 = 0;
      _fx_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_10 = {0};
      _fx_T2N10Ast__pat_tN10Ast__exp_t* __pat___0 = &lst_0->hd;
      FX_COPY_PTR(__pat___0->t0, &pj_0);
      FX_COPY_PTR(__pat___0->t1, &trj_0);
      _fx_copy_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&__fold_result___0, &v_8);
      FX_COPY_PTR(v_8.t0, &code_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_8.t1, &env_3);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_8.t2, &idset_1);
      FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(trj_0, &v_9, 0), _fx_catch_7);
      FX_COPY_PTR(v_9.t0, &ttrj_0);
      _fx_R10Ast__loc_t locj_0 = v_9.t1;
      if (FX_REC_VARIANT_TAG(ttrj_0) == 17) {
         _fx_N10Ast__typ_t result_0 = 0;
         _fx_LN10Ast__typ_t l_0 = 0;
         _fx_N10Ast__typ_t tj_0 = 0;
         _fx_N10Ast__lit_t v_11 = {0};
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_12 = {0};
         _fx_N10Ast__exp_t v_13 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_14 = {0};
         _fx_N10Ast__exp_t ej_0 = 0;
         _fx_N10Ast__pat_t pj_1 = 0;
         _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_15 = {0};
         _fx_N10Ast__pat_t pj_2 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_4 = {0};
         _fx_Rt6Set__t1R9Ast__id_t idset_2 = {0};
         _fx_R16Ast__val_flags_t v_16 = {0};
         _fx_N10Ast__exp_t def_pj_0 = 0;
         _fx_LN10Ast__exp_t v_17 = 0;
         FX_COPY_PTR(ttrj_0->u.TypTuple, &l_0);
         int_ n_0 = idx_0;
         for (;;) {
            _fx_LN10Ast__typ_t l_1 = 0;
            FX_COPY_PTR(l_0, &l_1);
            int_ n_1 = n_0;
            if (l_1 != 0) {
               if (n_1 == 0) {
                  _fx_N10Ast__typ_t* a_0 = &l_1->hd;
                  _fx_free_N10Ast__typ_t(&result_0);
                  FX_COPY_PTR(*a_0, &result_0);
                  FX_BREAK(_fx_catch_0);
               }
               else {
                  _fx_LN10Ast__typ_t* rest_0 = &l_1->tl;
                  _fx_free_LN10Ast__typ_t(&l_0);
                  FX_COPY_PTR(*rest_0, &l_0);
                  n_0 = n_1 - 1;
               }

            _fx_catch_0: ;
            }
            else {
               FX_FAST_THROW(FX_EXN_OutOfRangeError, _fx_catch_1);
            }
            FX_CHECK_EXN(_fx_catch_1);

         _fx_catch_1: ;
            if (l_1) {
               _fx_free_LN10Ast__typ_t(&l_1);
            }
            FX_CHECK_BREAK();
            FX_CHECK_EXN(_fx_catch_2);
         }
         FX_COPY_PTR(result_0, &tj_0);
         _fx_M3AstFM6LitIntN10Ast__lit_t1l((int64_t)idx_0, &v_11);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &locj_0, &v_12);
         FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_11, &v_12, &v_13), _fx_catch_2);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(tj_0, &locj_0, &v_14);
         FX_CALL(_fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(trj_0, v_13, &v_14, &ej_0),
            _fx_catch_2);
         FX_CALL(_fx_M3AstFM7dup_patN10Ast__pat_t1N10Ast__pat_t(pj_0, &pj_1, 0), _fx_catch_2);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
               pj_1, tj_0, &env_3, &idset_1, &_fx_g16Ast__empty_idset, sc_1, false, true, false, &v_15, 0), _fx_catch_2);
         FX_COPY_PTR(v_15.t0, &pj_2);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_15.t1, &env_4);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_15.t2, &idset_2);
         FX_CALL(_fx_M3AstFM21default_tempval_flagsRM11val_flags_t0(&v_16, 0), _fx_catch_2);
         FX_CALL(
            _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(pj_2, ej_0, &v_16, &locj_0,
               &def_pj_0), _fx_catch_2);
         FX_CALL(_fx_cons_LN10Ast__exp_t(def_pj_0, code_2, true, &v_17), _fx_catch_2);
         _fx_make_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(v_17, &env_4, &idset_2, &v_10);

      _fx_catch_2: ;
         if (v_17) {
            _fx_free_LN10Ast__exp_t(&v_17);
         }
         if (def_pj_0) {
            _fx_free_N10Ast__exp_t(&def_pj_0);
         }
         _fx_free_R16Ast__val_flags_t(&v_16);
         _fx_free_Rt6Set__t1R9Ast__id_t(&idset_2);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_4);
         if (pj_2) {
            _fx_free_N10Ast__pat_t(&pj_2);
         }
         _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_15);
         if (pj_1) {
            _fx_free_N10Ast__pat_t(&pj_1);
         }
         if (ej_0) {
            _fx_free_N10Ast__exp_t(&ej_0);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_14);
         if (v_13) {
            _fx_free_N10Ast__exp_t(&v_13);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_12);
         _fx_free_N10Ast__lit_t(&v_11);
         if (tj_0) {
            _fx_free_N10Ast__typ_t(&tj_0);
         }
         if (l_0) {
            _fx_free_LN10Ast__typ_t(&l_0);
         }
         if (result_0) {
            _fx_free_N10Ast__typ_t(&result_0);
         }
      }
      else {
         _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_18 = {0};
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_0 = 0;
         _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t result_1 = {0};
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t l_2 = 0;
         _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_19 = {0};
         _fx_N10Ast__typ_t tj_1 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_20 = {0};
         _fx_N10Ast__exp_t v_21 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_22 = {0};
         _fx_N10Ast__exp_t ej_1 = 0;
         _fx_N10Ast__pat_t pj_3 = 0;
         _fx_N10Ast__pat_t v_23 = 0;
         _fx_Ta2N10Ast__pat_t v_24 = {0};
         _fx_N10Ast__pat_t pnj_0 = 0;
         _fx_N10Ast__pat_t pvj_0 = 0;
         _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_25 = {0};
         _fx_N10Ast__pat_t pnj_1 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_5 = {0};
         _fx_Rt6Set__t1R9Ast__id_t idset_3 = {0};
         _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_26 = {0};
         _fx_N10Ast__pat_t pvj_1 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_6 = {0};
         _fx_Rt6Set__t1R9Ast__id_t idset_4 = {0};
         _fx_R16Ast__val_flags_t v_27 = {0};
         _fx_N10Ast__exp_t def_pvj_0 = 0;
         fx_str_t v_28 = {0};
         _fx_N10Ast__lit_t v_29 = {0};
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_30 = {0};
         _fx_N10Ast__exp_t v_31 = 0;
         _fx_R16Ast__val_flags_t v_32 = {0};
         _fx_N10Ast__exp_t def_pnj_0 = 0;
         _fx_LN10Ast__exp_t v_33 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM16get_record_elemsT2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t4Nt6option1R9Ast__id_tN10Ast__typ_tBR10Ast__loc_t(
               &_fx_g21Ast_typecheck__None9_, ttrj_0, false, &locj_0, &v_18, 0), _fx_catch_6);
         FX_COPY_PTR(v_18.t1, &relems_0);
         FX_COPY_PTR(relems_0, &l_2);
         int_ n_2 = idx_0;
         for (;;) {
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t l_3 = 0;
            FX_COPY_PTR(l_2, &l_3);
            int_ n_3 = n_2;
            if (l_3 != 0) {
               if (n_3 == 0) {
                  _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* a_1 = &l_3->hd;
                  _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&result_1);
                  _fx_copy_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(a_1, &result_1);
                  FX_BREAK(_fx_catch_3);
               }
               else {
                  _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* rest_1 = &l_3->tl;
                  _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&l_2);
                  FX_COPY_PTR(*rest_1, &l_2);
                  n_2 = n_3 - 1;
               }

            _fx_catch_3: ;
            }
            else {
               FX_FAST_THROW(FX_EXN_OutOfRangeError, _fx_catch_4);
            }
            FX_CHECK_EXN(_fx_catch_4);

         _fx_catch_4: ;
            if (l_3) {
               _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&l_3);
            }
            FX_CHECK_BREAK();
            FX_CHECK_EXN(_fx_catch_6);
         }
         _fx_copy_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&result_1, &v_19);
         _fx_R9Ast__id_t nj_0 = v_19.t1;
         FX_COPY_PTR(v_19.t2, &tj_1);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g24Ast_typecheck__TypString, &locj_0, &v_20);
         FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&nj_0, &v_20, &v_21), _fx_catch_6);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(tj_1, &locj_0, &v_22);
         FX_CALL(_fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(trj_0, v_21, &v_22, &ej_1),
            _fx_catch_6);
         FX_CALL(_fx_M3AstFM7dup_patN10Ast__pat_t1N10Ast__pat_t(pj_0, &pj_3, 0), _fx_catch_6);
         FX_CALL(_fx_M3AstFM14pat_skip_typedN10Ast__pat_t1N10Ast__pat_t(pj_3, &v_23, 0), _fx_catch_6);
         int tag_0 = FX_REC_VARIANT_TAG(v_23);
         if (tag_0 == 4) {
            _fx_LN10Ast__pat_t v_34 = v_23->u.PatTuple.t0;
            if (v_34 != 0) {
               _fx_LN10Ast__pat_t v_35 = v_34->tl;
               if (v_35 != 0) {
                  if (v_35->tl == 0) {
                     _fx_make_Ta2N10Ast__pat_t(v_34->hd, v_35->hd, &v_24); goto _fx_endmatch_0;
                  }
               }
            }
         }
         if (tag_0 == 8) {
            _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t* vcase_0 = &v_23->u.PatAs;
            _fx_N10Ast__pat_t v_36 = vcase_0->t0;
            if (FX_REC_VARIANT_TAG(v_36) == 4) {
               _fx_LN10Ast__pat_t v_37 = v_36->u.PatTuple.t0;
               if (v_37 != 0) {
                  _fx_LN10Ast__pat_t v_38 = v_37->tl;
                  if (v_38 != 0) {
                     if (v_38->tl == 0) {
                        _fx_R9Ast__id_t v_39;
                        FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&vcase_0->t1, &v_39, 0), _fx_catch_6);
                        bool res_0;
                        FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_39, &_fx_g15Ast__std__pat__, &res_0, 0), _fx_catch_6);
                        if (res_0) {
                           _fx_make_Ta2N10Ast__pat_t(v_37->hd, v_38->hd, &v_24); goto _fx_endmatch_0;
                        }
                     }
                  }
               }
            }
         }
         fx_exn_t v_40 = {0};
         fx_str_t slit_0 = FX_MAKE_STR("when iterating through record, a 2-element tuple should be used as pattern");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &slit_0, &v_40, 0), _fx_catch_5);
         FX_THROW(&v_40, false, _fx_catch_5);

      _fx_catch_5: ;
         fx_free_exn(&v_40);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_6);
         FX_COPY_PTR(v_24.t0, &pnj_0);
         FX_COPY_PTR(v_24.t1, &pvj_0);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
               pnj_0, _fx_g24Ast_typecheck__TypString, &env_3, &idset_1, &_fx_g16Ast__empty_idset, sc_1, false, true, false,
               &v_25, 0), _fx_catch_6);
         FX_COPY_PTR(v_25.t0, &pnj_1);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_25.t1, &env_5);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_25.t2, &idset_3);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
               pvj_0, tj_1, &env_5, &idset_3, &_fx_g16Ast__empty_idset, sc_1, false, true, false, &v_26, 0), _fx_catch_6);
         FX_COPY_PTR(v_26.t0, &pvj_1);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_26.t1, &env_6);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_26.t2, &idset_4);
         FX_CALL(_fx_M3AstFM21default_tempval_flagsRM11val_flags_t0(&v_27, 0), _fx_catch_6);
         FX_CALL(
            _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(pvj_1, ej_1, &v_27, &locj_0,
               &def_pvj_0), _fx_catch_6);
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&nj_0, &v_28, 0), _fx_catch_6);
         _fx_M3AstFM9LitStringN10Ast__lit_t1S(&v_28, &v_29);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g24Ast_typecheck__TypString, &locj_0, &v_30);
         FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_29, &v_30, &v_31), _fx_catch_6);
         FX_CALL(_fx_M3AstFM21default_tempval_flagsRM11val_flags_t0(&v_32, 0), _fx_catch_6);
         FX_CALL(
            _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(pnj_1, v_31, &v_32, &locj_0,
               &def_pnj_0), _fx_catch_6);
         FX_CALL(_fx_cons_LN10Ast__exp_t(def_pnj_0, code_2, true, &v_33), _fx_catch_6);
         FX_CALL(_fx_cons_LN10Ast__exp_t(def_pvj_0, v_33, false, &v_33), _fx_catch_6);
         _fx_make_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(v_33, &env_6, &idset_4, &v_10);

      _fx_catch_6: ;
         if (v_33) {
            _fx_free_LN10Ast__exp_t(&v_33);
         }
         if (def_pnj_0) {
            _fx_free_N10Ast__exp_t(&def_pnj_0);
         }
         _fx_free_R16Ast__val_flags_t(&v_32);
         if (v_31) {
            _fx_free_N10Ast__exp_t(&v_31);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_30);
         _fx_free_N10Ast__lit_t(&v_29);
         FX_FREE_STR(&v_28);
         if (def_pvj_0) {
            _fx_free_N10Ast__exp_t(&def_pvj_0);
         }
         _fx_free_R16Ast__val_flags_t(&v_27);
         _fx_free_Rt6Set__t1R9Ast__id_t(&idset_4);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_6);
         if (pvj_1) {
            _fx_free_N10Ast__pat_t(&pvj_1);
         }
         _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_26);
         _fx_free_Rt6Set__t1R9Ast__id_t(&idset_3);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_5);
         if (pnj_1) {
            _fx_free_N10Ast__pat_t(&pnj_1);
         }
         _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_25);
         if (pvj_0) {
            _fx_free_N10Ast__pat_t(&pvj_0);
         }
         if (pnj_0) {
            _fx_free_N10Ast__pat_t(&pnj_0);
         }
         _fx_free_Ta2N10Ast__pat_t(&v_24);
         if (v_23) {
            _fx_free_N10Ast__pat_t(&v_23);
         }
         if (pj_3) {
            _fx_free_N10Ast__pat_t(&pj_3);
         }
         if (ej_1) {
            _fx_free_N10Ast__exp_t(&ej_1);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_22);
         if (v_21) {
            _fx_free_N10Ast__exp_t(&v_21);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_20);
         if (tj_1) {
            _fx_free_N10Ast__typ_t(&tj_1);
         }
         _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_19);
         if (l_2) {
            _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&l_2);
         }
         _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&result_1);
         if (relems_0) {
            _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_0);
         }
         _fx_free_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_18);
      }
      FX_CHECK_EXN(_fx_catch_7);
      _fx_free_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&__fold_result___0);
      _fx_copy_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_10, &__fold_result___0);

   _fx_catch_7: ;
      _fx_free_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_10);
      if (ttrj_0) {
         _fx_free_N10Ast__typ_t(&ttrj_0);
      }
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_9);
      _fx_free_Rt6Set__t1R9Ast__id_t(&idset_1);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
      if (code_2) {
         _fx_free_LN10Ast__exp_t(&code_2);
      }
      _fx_free_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_8);
      if (trj_0) {
         _fx_free_N10Ast__exp_t(&trj_0);
      }
      if (pj_0) {
         _fx_free_N10Ast__pat_t(&pj_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&__fold_result___0, &v_0);
   FX_COPY_PTR(v_0.t0, &code_0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0.t1, &env_1);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&v_0.t2, &idset_0);
   if (FX_REC_VARIANT_TAG(idx_pat_0) == 1) {
      _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(code_0, &env_1, &v_1);
   }
   else {
      _fx_N10Ast__pat_t idx_pat_1 = 0;
      _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_41 = {0};
      _fx_N10Ast__pat_t idx_pat_2 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_7 = {0};
      _fx_N10Ast__lit_t v_42 = {0};
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_43 = {0};
      _fx_N10Ast__exp_t v_44 = 0;
      _fx_R16Ast__val_flags_t v_45 = {0};
      _fx_N10Ast__exp_t def_idx_0 = 0;
      _fx_LN10Ast__exp_t v_46 = 0;
      FX_CALL(_fx_M3AstFM7dup_patN10Ast__pat_t1N10Ast__pat_t(idx_pat_0, &idx_pat_1, 0), _fx_catch_8);
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
            idx_pat_1, _fx_g21Ast_typecheck__TypInt, &env_1, &idset_0, &_fx_g16Ast__empty_idset, sc_1, false, true, false,
            &v_41, 0), _fx_catch_8);
      FX_COPY_PTR(v_41.t0, &idx_pat_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_41.t1, &env_7);
      _fx_R10Ast__loc_t idx_loc_0;
      FX_CALL(_fx_M3AstFM11get_pat_locRM5loc_t1N10Ast__pat_t(idx_pat_2, &idx_loc_0, 0), _fx_catch_8);
      _fx_M3AstFM6LitIntN10Ast__lit_t1l((int64_t)idx_0, &v_42);
      _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &idx_loc_0, &v_43);
      FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_42, &v_43, &v_44), _fx_catch_8);
      FX_CALL(_fx_M3AstFM21default_tempval_flagsRM11val_flags_t0(&v_45, 0), _fx_catch_8);
      FX_CALL(
         _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(idx_pat_2, v_44, &v_45, &idx_loc_0,
            &def_idx_0), _fx_catch_8);
      FX_CALL(_fx_cons_LN10Ast__exp_t(def_idx_0, code_0, true, &v_46), _fx_catch_8);
      _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_46, &env_7, &v_1);

   _fx_catch_8: ;
      if (v_46) {
         _fx_free_LN10Ast__exp_t(&v_46);
      }
      if (def_idx_0) {
         _fx_free_N10Ast__exp_t(&def_idx_0);
      }
      _fx_free_R16Ast__val_flags_t(&v_45);
      if (v_44) {
         _fx_free_N10Ast__exp_t(&v_44);
      }
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_43);
      _fx_free_N10Ast__lit_t(&v_42);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_7);
      if (idx_pat_2) {
         _fx_free_N10Ast__pat_t(&idx_pat_2);
      }
      _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_41);
      if (idx_pat_1) {
         _fx_free_N10Ast__pat_t(&idx_pat_1);
      }
   }
   FX_CHECK_EXN(_fx_cleanup);
   FX_COPY_PTR(v_1.t0, &code_1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_1.t1, &env_2);
   FX_CALL(_fx_M3AstFM7dup_expN10Ast__exp_t1N10Ast__exp_t(body_0, &v_2, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(v_2,
         &env_2, sc_1, &body_1, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(body_1, &v_3, 0), _fx_cleanup);
   FX_COPY_PTR(v_3.t0, &body_typ_0);
   _fx_R10Ast__loc_t body_loc_0 = v_3.t1;
   FX_CALL(_fx_cons_LN10Ast__exp_t(body_1, code_1, true, &v_4), _fx_cleanup);
   _fx_LN10Ast__exp_t lst_1 = v_4;
   for (; lst_1; lst_1 = lst_1->tl) {
      _fx_LN10Ast__exp_t r_0 = 0;
      _fx_N10Ast__exp_t a_2 = lst_1->hd;
      FX_COPY_PTR(__fold_result___1, &r_0);
      FX_CALL(_fx_cons_LN10Ast__exp_t(a_2, r_0, false, &r_0), _fx_catch_9);
      _fx_free_LN10Ast__exp_t(&__fold_result___1);
      FX_COPY_PTR(r_0, &__fold_result___1);

   _fx_catch_9: ;
      if (r_0) {
         _fx_free_LN10Ast__exp_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___1, &v_5);
   _fx_make_T2N10Ast__typ_tR10Ast__loc_t(body_typ_0, &body_loc_0, &v_6);
   FX_CALL(_fx_M3AstFM6ExpSeqN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_5, &v_6, fx_result), _fx_cleanup);

_fx_cleanup: ;
   FX_FREE_LIST_SIMPLE(&sc_1);
   _fx_free_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&__fold_result___0);
   _fx_free_T3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_0);
   if (code_0) {
      _fx_free_LN10Ast__exp_t(&code_0);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   _fx_free_Rt6Set__t1R9Ast__id_t(&idset_0);
   _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_1);
   if (code_1) {
      _fx_free_LN10Ast__exp_t(&code_1);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
   if (v_2) {
      _fx_free_N10Ast__exp_t(&v_2);
   }
   if (body_1) {
      _fx_free_N10Ast__exp_t(&body_1);
   }
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_3);
   if (body_typ_0) {
      _fx_free_N10Ast__typ_t(&body_typ_0);
   }
   if (v_4) {
      _fx_free_LN10Ast__exp_t(&v_4);
   }
   if (__fold_result___1) {
      _fx_free_LN10Ast__exp_t(&__fold_result___1);
   }
   if (v_5) {
      _fx_free_LN10Ast__exp_t(&v_5);
   }
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_6);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM16check_inside_forv5BBBLN12Ast__scope_tR10Ast__loc_t(
   bool expect_fold_loop_0,
   bool isbr_0,
   bool any_for_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   void* fx_fv)
{
   fx_str_t kw_0 = {0};
   int fx_status = 0;
   if (!isbr_0) {
      fx_str_t slit_0 = FX_MAKE_STR("continue"); fx_copy_str(&slit_0, &kw_0);
   }
   else if (expect_fold_loop_0) {
      fx_str_t slit_1 = FX_MAKE_STR("fold\'s break"); fx_copy_str(&slit_1, &kw_0);
   }
   else {
      fx_str_t slit_2 = FX_MAKE_STR("break"); fx_copy_str(&slit_2, &kw_0);
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM13check_inside_v6LN12Ast__scope_tBR10Ast__loc_tBBS(sc_0, any_for_0, eloc_0, expect_fold_loop_0,
         isbr_0, &kw_0, 0), _fx_cleanup);

_fx_cleanup: ;
   FX_FREE_STR(&kw_0);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM13check_inside_v6LN12Ast__scope_tBR10Ast__loc_tBBS(
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool any_for_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   bool expect_fold_loop_0,
   bool isbr_0,
   fx_str_t* kw_0,
   void* fx_fv)
{
   _fx_LN12Ast__scope_t sc_1 = 0;
   int fx_status = 0;
   FX_COPY_PTR(sc_0, &sc_1);
   bool t_0;
   if (!any_for_0) {
      t_0 = !expect_fold_loop_0;
   }
   else {
      t_0 = false;
   }
   bool t_1;
   if (!any_for_0) {
      t_1 = expect_fold_loop_0;
   }
   else {
      t_1 = false;
   }
   for (;;) {
      _fx_LN12Ast__scope_t sc_2 = 0;
      FX_COPY_PTR(sc_1, &sc_2);
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 6) {
            fx_str_t v_0 = {0};
            fx_exn_t v_1 = {0};
            if (!any_for_0) {
               fx_str_t slit_0 = FX_MAKE_STR("cannot use \'");
               fx_str_t slit_1 = FX_MAKE_STR("\' inside \'try-catch\' block");
               {
                  const fx_str_t strs_0[] = { slit_0, *kw_0, slit_1 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &v_0), _fx_catch_0);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_0, &v_1, 0), _fx_catch_0);
               FX_THROW(&v_1, false, _fx_catch_0);
            }
            _fx_LN12Ast__scope_t* outer_sc_0 = &sc_2->tl;
            FX_FREE_LIST_SIMPLE(&sc_1);
            FX_COPY_PTR(*outer_sc_0, &sc_1);

         _fx_catch_0: ;
            fx_free_exn(&v_1);
            FX_FREE_STR(&v_0);
            goto _fx_endmatch_1;
         }
      }
      bool res_0;
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 7) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 10) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 8) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 9) {
            res_0 = true; goto _fx_endmatch_0;
         }
      }
      if (sc_2 == 0) {
         res_0 = true; goto _fx_endmatch_0;
      }
      res_0 = false;

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_6);
      if (res_0) {
         fx_str_t v_2 = {0};
         fx_exn_t v_3 = {0};
         fx_str_t slit_2 = FX_MAKE_STR("cannot use \'");
         fx_str_t slit_3 = FX_MAKE_STR("\' outside of loop");
         {
            const fx_str_t strs_1[] = { slit_2, *kw_0, slit_3 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_1, 3, &v_2), _fx_catch_1);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_2, &v_3, 0), _fx_catch_1);
         FX_THROW(&v_3, false, _fx_catch_1);

      _fx_catch_1: ;
         fx_free_exn(&v_3);
         FX_FREE_STR(&v_2);
         goto _fx_endmatch_1;
      }
      if (sc_2 != 0) {
         _fx_N12Ast__scope_t* v_4 = &sc_2->hd;
         if (v_4->tag == 2) {
            fx_str_t v_5 = {0};
            fx_exn_t v_6 = {0};
            fx_exn_t v_7 = {0};
            if (!any_for_0) {
               if (expect_fold_loop_0) {
                  fx_str_t slit_4 = FX_MAKE_STR("\'");
                  fx_str_t slit_5 = FX_MAKE_STR("\' can only be used inside \'fold\' loop");
                  {
                     const fx_str_t strs_2[] = { slit_4, *kw_0, slit_5 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_2, 3, &v_5), _fx_catch_2);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_5, &v_6, 0), _fx_catch_2);
                  FX_THROW(&v_6, false, _fx_catch_2);
               }
               else {
                  bool t_2;
                  if (isbr_0) {
                     t_2 = v_4->u.ScLoop.t0;
                  }
                  else {
                     t_2 = false;
                  }
                  if (t_2) {
                     fx_str_t slit_6 =
                        FX_MAKE_STR(
                           "\'break\' cannot be used inside nested for-loop because of ambiguity. Use explicit curly braces, e.g. \'for ... { for ... { for ... { break }}}\' to exit a single for-loop, or use exceptions, e.g. the standard \'Break\' exception to exit nested loops.");
                     FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &slit_6, &v_7, 0), _fx_catch_2);
                     FX_THROW(&v_7, false, _fx_catch_2);
                  }
                  else {
                     FX_BREAK(_fx_catch_2);
                  }
               }
            }
            else {
               FX_BREAK(_fx_catch_2);
            }

         _fx_catch_2: ;
            fx_free_exn(&v_7);
            fx_free_exn(&v_6);
            FX_FREE_STR(&v_5);
            goto _fx_endmatch_1;
         }
      }
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 3) {
            fx_str_t v_8 = {0};
            fx_exn_t v_9 = {0};
            if (t_0) {
               fx_str_t slit_7 = FX_MAKE_STR("cannot use \'");
               fx_str_t slit_8 = FX_MAKE_STR("\' inside \'fold\' loop");
               {
                  const fx_str_t strs_3[] = { slit_7, *kw_0, slit_8 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_3, 3, &v_8), _fx_catch_3);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_8, &v_9, 0), _fx_catch_3);
               FX_THROW(&v_9, false, _fx_catch_3);
            }
            else {
               FX_BREAK(_fx_catch_3);
            }

         _fx_catch_3: ;
            fx_free_exn(&v_9);
            FX_FREE_STR(&v_8);
            goto _fx_endmatch_1;
         }
      }
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 4) {
            fx_str_t v_10 = {0};
            fx_exn_t v_11 = {0};
            if (!any_for_0) {
               fx_str_t slit_9 = FX_MAKE_STR("cannot use \'");
               fx_str_t slit_10 = FX_MAKE_STR("\' inside array comprehension");
               {
                  const fx_str_t strs_4[] = { slit_9, *kw_0, slit_10 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_4, 3, &v_10), _fx_catch_4);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_10, &v_11, 0), _fx_catch_4);
               FX_THROW(&v_11, false, _fx_catch_4);
            }
            else {
               FX_BREAK(_fx_catch_4);
            }

         _fx_catch_4: ;
            fx_free_exn(&v_11);
            FX_FREE_STR(&v_10);
            goto _fx_endmatch_1;
         }
      }
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 5) {
            fx_str_t v_12 = {0};
            fx_exn_t v_13 = {0};
            if (t_1) {
               fx_str_t slit_11 = FX_MAKE_STR("\'");
               fx_str_t slit_12 = FX_MAKE_STR("\' can only be used inside \'fold\' loop");
               {
                  const fx_str_t strs_5[] = { slit_11, *kw_0, slit_12 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_5, 3, &v_12), _fx_catch_5);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_12, &v_13, 0), _fx_catch_5);
               FX_THROW(&v_13, false, _fx_catch_5);
            }
            else {
               FX_BREAK(_fx_catch_5);
            }

         _fx_catch_5: ;
            fx_free_exn(&v_13);
            FX_FREE_STR(&v_12);
            goto _fx_endmatch_1;
         }
      }
      if (sc_2 != 0) {
         if (sc_2->hd.tag == 1) {
            _fx_LN12Ast__scope_t* outer_sc_1 = &sc_2->tl;
            FX_FREE_LIST_SIMPLE(&sc_1);
            FX_COPY_PTR(*outer_sc_1, &sc_1);
            goto _fx_endmatch_1;
         }
      }
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_6);

   _fx_endmatch_1: ;
      FX_CHECK_EXN(_fx_catch_6);

   _fx_catch_6: ;
      FX_FREE_LIST_SIMPLE(&sc_2);
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }

_fx_cleanup: ;
   FX_FREE_LIST_SIMPLE(&sc_1);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM19check_and_make_callN10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
   struct _fx_R9Ast__id_t* f_id_0,
   struct _fx_LN10Ast__exp_t_data_t* args_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* ctx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_N10Ast__typ_t_data_t* etyp_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LN10Ast__typ_t arg_typs_0 = 0;
   _fx_N10Ast__typ_t f_expected_typ_0 = 0;
   _fx_N10Ast__typ_t v_0 = 0;
   _fx_T2N10Ast__typ_tR10Ast__loc_t v_1 = {0};
   _fx_N10Ast__exp_t f_exp_0 = 0;
   _fx_T2N10Ast__typ_tR10Ast__loc_t v_2 = {0};
   _fx_N10Ast__typ_t f_real_typ_0 = 0;
   fx_str_t v_3 = {0};
   fx_str_t v_4 = {0};
   fx_str_t v_5 = {0};
   fx_exn_t v_6 = {0};
   _fx_N10Ast__exp_t new_f_0 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_LN10Ast__typ_t lstend_0 = 0;
   _fx_LN10Ast__exp_t lst_0 = args_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__typ_t res_0 = 0;
      _fx_N10Ast__exp_t a_0 = lst_0->hd;
      FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(a_0, &res_0, 0), _fx_catch_0);
      _fx_LN10Ast__typ_t node_0 = 0;
      FX_CALL(_fx_cons_LN10Ast__typ_t(res_0, 0, false, &node_0), _fx_catch_0);
      FX_LIST_APPEND(arg_typs_0, lstend_0, node_0);

   _fx_catch_0: ;
      if (res_0) {
         _fx_free_N10Ast__typ_t(&res_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(arg_typs_0, etyp_0, &f_expected_typ_0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_0, 0), _fx_cleanup);
   _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_0, eloc_0, &v_1);
   FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(f_id_0, &v_1, &f_exp_0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(f_exp_0, &v_2, 0), _fx_cleanup);
   FX_COPY_PTR(v_2.t0, &f_real_typ_0);
   _fx_R10Ast__loc_t floc_0 = v_2.t1;
   FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(f_real_typ_0, &v_3, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(f_expected_typ_0, &v_4, 0), _fx_cleanup);
   fx_str_t slit_0 = FX_MAKE_STR("the real \'");
   fx_str_t slit_1 = FX_MAKE_STR("\' and expected \'");
   fx_str_t slit_2 = FX_MAKE_STR("\' function type do not match");
   {
      const fx_str_t strs_0[] = { slit_0, v_3, slit_1, v_4, slit_2 };
      FX_CALL(fx_strjoin(0, 0, 0, strs_0, 5, &v_5), _fx_cleanup);
   }
   bool v_7;
   FX_CALL(
      _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(f_real_typ_0, f_expected_typ_0, &floc_0,
         true, &v_7, 0), _fx_cleanup);
   if (!v_7) {
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&floc_0, &v_5, &v_6, 0), _fx_cleanup); FX_THROW(&v_6, false, _fx_cleanup);
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
         f_exp_0, env_0, sc_0, &new_f_0, 0), _fx_cleanup);
   FX_CALL(
      _fx_M3AstFM7ExpCallN10Ast__exp_t3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(new_f_0, args_0, ctx_0, fx_result),
      _fx_cleanup);

_fx_cleanup: ;
   if (arg_typs_0) {
      _fx_free_LN10Ast__typ_t(&arg_typs_0);
   }
   if (f_expected_typ_0) {
      _fx_free_N10Ast__typ_t(&f_expected_typ_0);
   }
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_1);
   if (f_exp_0) {
      _fx_free_N10Ast__exp_t(&f_exp_0);
   }
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_2);
   if (f_real_typ_0) {
      _fx_free_N10Ast__typ_t(&f_real_typ_0);
   }
   FX_FREE_STR(&v_3);
   FX_FREE_STR(&v_4);
   FX_FREE_STR(&v_5);
   fx_free_exn(&v_6);
   if (new_f_0) {
      _fx_free_N10Ast__exp_t(&new_f_0);
   }
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM15maybe_make_callNt6option1N10Ast__exp_t7R9Ast__id_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_t(
   struct _fx_R9Ast__id_t* f_id_0,
   struct _fx_LN10Ast__exp_t_data_t* args_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* ctx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_N10Ast__typ_t_data_t* etyp_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Nt6option1N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LN10Ast__typ_t arg_typs_0 = 0;
   _fx_N10Ast__typ_t f_expected_typ_0 = 0;
   _fx_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t v_0 = {0};
   _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t id_n_typ_0 = {0};
   int fx_status = 0;
   _fx_LN10Ast__typ_t lstend_0 = 0;
   _fx_LN10Ast__exp_t lst_0 = args_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__typ_t res_0 = 0;
      _fx_N10Ast__exp_t a_0 = lst_0->hd;
      FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(a_0, &res_0, 0), _fx_catch_0);
      _fx_LN10Ast__typ_t node_0 = 0;
      FX_CALL(_fx_cons_LN10Ast__typ_t(res_0, 0, false, &node_0), _fx_catch_0);
      FX_LIST_APPEND(arg_typs_0, lstend_0, node_0);

   _fx_catch_0: ;
      if (res_0) {
         _fx_free_N10Ast__typ_t(&res_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(arg_typs_0, etyp_0, &f_expected_typ_0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM13lookup_id_optT2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
         f_id_0, f_expected_typ_0, env_0, sc_0, eloc_0, &v_0, 0), _fx_cleanup);
   _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_0.t0, &id_n_typ_0);
   int tag_0 = id_n_typ_0.tag;
   if (tag_0 == 2) {
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_1 = {0};
      _fx_N10Ast__exp_t v_2 = 0;
      _fx_N10Ast__exp_t v_3 = 0;
      _fx_T2R9Ast__id_tN10Ast__typ_t* v_4 = &id_n_typ_0.u.Some;
      _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_4->t1, eloc_0, &v_1);
      FX_CALL(_fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&v_4->t0, &v_1, &v_2), _fx_catch_1);
      FX_CALL(_fx_M3AstFM7ExpCallN10Ast__exp_t3N10Ast__exp_tLN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_2, args_0, ctx_0, &v_3),
         _fx_catch_1);
      FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(v_3, fx_result), _fx_catch_1);

   _fx_catch_1: ;
      if (v_3) {
         _fx_free_N10Ast__exp_t(&v_3);
      }
      if (v_2) {
         _fx_free_N10Ast__exp_t(&v_2);
      }
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_1);
   }
   else if (tag_0 == 1) {
      FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, fx_result);
   }
   else {
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_cleanup);
   }

_fx_cleanup: ;
   if (arg_typs_0) {
      _fx_free_LN10Ast__typ_t(&arg_typs_0);
   }
   if (f_expected_typ_0) {
      _fx_free_N10Ast__typ_t(&f_expected_typ_0);
   }
   _fx_free_T2Nt6option1T2R9Ast__id_tN10Ast__typ_tLN16Ast__env_entry_t(&v_0);
   _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&id_n_typ_0);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM9is_lvalueB4BN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_t(
   bool need_mutable_id_0,
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* ectx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__exp_t e_1 = 0;
   _fx_T2N10Ast__typ_tR10Ast__loc_t ectx_1 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   bool result_0 = 0;
   bool need_mutable_id_1 = need_mutable_id_0;
   FX_COPY_PTR(e_0, &e_1);
   _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(ectx_0, &ectx_1);
   for (;;) {
      _fx_N10Ast__exp_t e_2 = 0;
      _fx_T2N10Ast__typ_tR10Ast__loc_t ectx_2 = {0};
      bool need_mutable_id_2 = need_mutable_id_1;
      FX_COPY_PTR(e_1, &e_2);
      _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&ectx_1, &ectx_2);
      int tag_0 = FX_REC_VARIANT_TAG(e_2);
      if (tag_0 == 19) {
         _fx_T5N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tLN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_0 =
            &e_2->u.ExpAt;
         if (vcase_0->t1.tag == 1) {
            if (vcase_0->t2.tag == 1) {
               need_mutable_id_1 = false;
               _fx_N10Ast__exp_t* arr_0 = &vcase_0->t0;
               _fx_free_N10Ast__exp_t(&e_1);
               FX_COPY_PTR(*arr_0, &e_1);
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&ectx_1);
               _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&ectx_2, &ectx_1);
               goto _fx_endmatch_0;
            }
         }
      }
      if (tag_0 == 9) {
         _fx_T3N12Ast__unary_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_1 = &e_2->u.ExpUnary;
         if (vcase_1->t0.tag == 7) {
            need_mutable_id_1 = false;
            _fx_N10Ast__exp_t* r_0 = &vcase_1->t1;
            _fx_free_N10Ast__exp_t(&e_1);
            FX_COPY_PTR(*r_0, &e_1);
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&ectx_1);
            _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&ectx_2, &ectx_1);
            goto _fx_endmatch_0;
         }
      }
      if (tag_0 == 7) {
         _fx_N14Ast__id_info_t v_0 = {0};
         if (!need_mutable_id_2) {
            result_0 = true; FX_BREAK(_fx_catch_2);
         }
         else {
            FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&e_2->u.ExpIdent.t0, eloc_0, &v_0, 0), _fx_catch_2);
            if (v_0.tag == 2) {
               result_0 = v_0.u.IdDVal.dv_flags.val_flag_mutable; FX_BREAK(_fx_catch_0);  _fx_catch_0: ;
            }
            else {
               result_0 = false; FX_BREAK(_fx_catch_1);  _fx_catch_1: ;
            }
            FX_CHECK_EXN(_fx_catch_2);
         }

      _fx_catch_2: ;
         _fx_free_N14Ast__id_info_t(&v_0);
         goto _fx_endmatch_0;
      }
      if (tag_0 == 21) {
         _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_2 = &e_2->u.ExpMem;
         _fx_N10Ast__exp_t v_1 = vcase_2->t1;
         if (FX_REC_VARIANT_TAG(v_1) == 7) {
            _fx_N10Ast__typ_t etyp_0 = 0;
            _fx_N10Ast__typ_t rtyp_0 = 0;
            _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_2 = {0};
            _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_0 = 0;
            _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t __fold_result___0 = {0};
            _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t __fold_result___1 = {0};
            _fx_R9Ast__id_t* n_0 = &v_1->u.ExpIdent.t0;
            _fx_N10Ast__exp_t rec_0 = vcase_2->t0;
            bool res_0;
            FX_CALL(
               _fx_M13Ast_typecheckFM9is_lvalueB4BN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_t(need_mutable_id_2,
                  rec_0, &ectx_2, eloc_0, &res_0, 0), _fx_catch_6);
            if (res_0) {
               result_0 = true; FX_BREAK(_fx_catch_6);
            }
            else {
               FX_COPY_PTR(ectx_2.t0, &etyp_0);
               _fx_R10Ast__loc_t exploc_0 = ectx_2.t1;
               FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(rec_0, &rtyp_0, 0), _fx_catch_6);
               FX_CALL(
                  _fx_M13Ast_typecheckFM16get_record_elemsT2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t4Nt6option1R9Ast__id_tN10Ast__typ_tBR10Ast__loc_t(
                     &_fx_g21Ast_typecheck__None9_, rtyp_0, false, &exploc_0, &v_2, 0), _fx_catch_6);
               FX_COPY_PTR(v_2.t1, &relems_0);
               _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&_fx_g21Ast_typecheck__None1_,
                  &__fold_result___0);
               _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_0 = relems_0;
               for (; lst_0; lst_0 = lst_0->tl) {
                  _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_3 = {0};
                  _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___0 = &lst_0->hd;
                  _fx_R9Ast__id_t nj_0 = __pat___0->t1;
                  _fx_R9Ast__id_t v_4;
                  FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&nj_0, &v_4, 0), _fx_catch_3);
                  _fx_R9Ast__id_t v_5;
                  FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(n_0, &v_5, 0), _fx_catch_3);
                  bool res_1;
                  FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_4, &v_5, &res_1, 0), _fx_catch_3);
                  if (res_1) {
                     _fx_M13Ast_typecheckFM4SomeNt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
                        __pat___0, &v_3);
                     _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___0);
                     _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_3, &__fold_result___0);
                     FX_BREAK(_fx_catch_3);
                  }

               _fx_catch_3: ;
                  _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_3);
                  FX_CHECK_BREAK();
                  FX_CHECK_EXN(_fx_catch_6);
               }
               _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___0,
                  &__fold_result___1);
               if (__fold_result___1.tag == 2) {
                  result_0 = __fold_result___1.u.Some.t0.val_flag_mutable; FX_BREAK(_fx_catch_4);  _fx_catch_4: ;
               }
               else {
                  fx_str_t v_6 = {0};
                  fx_str_t v_7 = {0};
                  fx_str_t v_8 = {0};
                  fx_exn_t v_9 = {0};
                  FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n_0, &v_6, 0), _fx_catch_5);
                  FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(etyp_0, &v_7, 0), _fx_catch_5);
                  fx_str_t slit_0 = FX_MAKE_STR("member \'");
                  fx_str_t slit_1 = FX_MAKE_STR("\' is not found the record of type \'");
                  fx_str_t slit_2 = FX_MAKE_STR("\'");
                  {
                     const fx_str_t strs_0[] = { slit_0, v_6, slit_1, v_7, slit_2 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_0, 5, &v_8), _fx_catch_5);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_8, &v_9, 0), _fx_catch_5);
                  FX_THROW(&v_9, false, _fx_catch_5);

               _fx_catch_5: ;
                  fx_free_exn(&v_9);
                  FX_FREE_STR(&v_8);
                  FX_FREE_STR(&v_7);
                  FX_FREE_STR(&v_6);
               }
               FX_CHECK_EXN(_fx_catch_6);
            }

         _fx_catch_6: ;
            _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___1);
            _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___0);
            if (relems_0) {
               _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_0);
            }
            _fx_free_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_2);
            if (rtyp_0) {
               _fx_free_N10Ast__typ_t(&rtyp_0);
            }
            if (etyp_0) {
               _fx_free_N10Ast__typ_t(&etyp_0);
            }
            goto _fx_endmatch_0;
         }
      }
      if (tag_0 == 21) {
         _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_3 = &e_2->u.ExpMem;
         if (FX_REC_VARIANT_TAG(vcase_3->t1) == 6) {
            need_mutable_id_1 = need_mutable_id_2;
            _fx_N10Ast__exp_t* tup_0 = &vcase_3->t0;
            _fx_free_N10Ast__exp_t(&e_1);
            FX_COPY_PTR(*tup_0, &e_1);
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&ectx_1);
            _fx_copy_T2N10Ast__typ_tR10Ast__loc_t(&ectx_2, &ectx_1);
            goto _fx_endmatch_0;
         }
      }
      result_0 = false;
      FX_BREAK(_fx_catch_7);

   _fx_catch_7: ;

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_8);

   _fx_catch_8: ;
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&ectx_2);
      if (e_2) {
         _fx_free_N10Ast__exp_t(&e_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = result_0;

_fx_cleanup: ;
   if (e_1) {
      _fx_free_N10Ast__exp_t(&e_1);
   }
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&ectx_1);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM32is_mutable_lvalue_identifier_expB3N10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   struct _fx_T2N10Ast__typ_tR10Ast__loc_t* ectx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   if (FX_REC_VARIANT_TAG(e_0) == 7) {
      _fx_N14Ast__id_info_t v_0 = {0};
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&e_0->u.ExpIdent.t0, eloc_0, &v_0, 0), _fx_catch_0);
      if (v_0.tag == 2) {
         *fx_result = v_0.u.IdDVal.dv_flags.val_flag_mutable;
      }
      else {
         *fx_result = false;
      }
      FX_CHECK_EXN(_fx_catch_0);

   _fx_catch_0: ;
      _fx_free_N14Ast__id_info_t(&v_0);
   }
   else {
      *fx_result = false;
   }
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM13check_range_eNt6option1N10Ast__exp_t3Nt6option1N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_Nt6option1N10Ast__exp_t_data_t* e_opt_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Nt6option1N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int tag_0 = (e_opt_0 != 0) + 1;
   if (tag_0 == 1) {
      FX_COPY_PTR(_fx_g22Ast_typecheck__None10_, fx_result);
   }
   else if (tag_0 == 2) {
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_0 = {0};
      _fx_N10Ast__typ_t etyp1_0 = 0;
      fx_exn_t v_1 = {0};
      _fx_N10Ast__exp_t new_e_0 = 0;
      _fx_N10Ast__exp_t e_0 = e_opt_0->u.Some;
      FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e_0, &v_0, 0), _fx_catch_0);
      FX_COPY_PTR(v_0.t0, &etyp1_0);
      _fx_R10Ast__loc_t eloc1_0 = v_0.t1;
      bool v_2;
      FX_CALL(
         _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(etyp1_0, _fx_g21Ast_typecheck__TypInt,
            &eloc1_0, true, &v_2, 0), _fx_catch_0);
      if (!v_2) {
         fx_str_t slit_0 = FX_MAKE_STR("explicitly specified component of a range must be an integer");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc1_0, &slit_0, &v_1, 0), _fx_catch_0);
         FX_THROW(&v_1, false, _fx_catch_0);
      }
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
            e_0, env_0, sc_0, &new_e_0, 0), _fx_catch_0);
      FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__exp_t1N10Ast__exp_t(new_e_0, fx_result), _fx_catch_0);

   _fx_catch_0: ;
      if (new_e_0) {
         _fx_free_N10Ast__exp_t(&new_e_0);
      }
      fx_free_exn(&v_1);
      if (etyp1_0) {
         _fx_free_N10Ast__typ_t(&etyp1_0);
      }
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_0);
   }
   else {
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_cleanup);
   }

_fx_cleanup: ;
   return fx_status;
}

static int _fx_M13Ast_typecheckFM10__lambda__B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* arg0_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM10__lambda__B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM10__lambda__B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_cldata_t*)fx_fv;
   _fx_R9Ast__id_t n1_0 = arg0_0->t1;
   FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&n1_0, &cv_0->t0, fx_result, 0), _fx_cleanup);

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1R9Ast__id_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(
      _fx_M13Ast_typecheckFM10__lambda__B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_cldata_t, fx_free,
      _fx_M13Ast_typecheckFM10__lambda__B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t);
   fcv->t0 = *arg0;
   return 0;
}

static int _fx_M13Ast_typecheckFM14is_simple_ctorB1N10Ast__exp_t(
   struct _fx_N10Ast__exp_t_data_t* e_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_R10Ast__loc_t eloc_0;
   FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(e_0, &eloc_0, 0), _fx_cleanup);
   if (FX_REC_VARIANT_TAG(e_0) == 7) {
      _fx_N14Ast__id_info_t v_0 = {0};
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&e_0->u.ExpIdent.t0, &eloc_0, &v_0, 0), _fx_catch_1);
      if (v_0.tag == 3) {
         _fx_R13Ast__deffun_t v_1 = {0};
         _fx_copy_R13Ast__deffun_t(&v_0.u.IdFun->data, &v_1);
         bool res_0;
         if (FX_REC_VARIANT_TAG(v_1.df_typ) == 14) {
            res_0 = false;
         }
         else {
            res_0 = true;
         }
         FX_CHECK_EXN(_fx_catch_0);
         if (res_0) {
            *fx_result = v_1.df_flags.fun_flag_ctor.tag != 1;
         }
         else {
            *fx_result = false;
         }

      _fx_catch_0: ;
         _fx_free_R13Ast__deffun_t(&v_1);
      }
      else {
         *fx_result = false;
      }
      FX_CHECK_EXN(_fx_catch_1);

   _fx_catch_1: ;
      _fx_free_N14Ast__id_info_t(&v_0);
   }
   else {
      *fx_result = false;
   }

_fx_cleanup: ;
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM10check_attrT3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t4N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* arr_0,
   struct _fx_N13Ast__border_t* border_0,
   struct _fx_N18Ast__interpolate_t* interp_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t* fx_result,
   void* fx_fv)
{
   _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t result_0 = {0};
   _fx_N10Ast__exp_t arr_1 = 0;
   int fx_status = 0;
   FX_COPY_PTR(arr_0, &arr_1);
   _fx_N13Ast__border_t border_1 = *border_0;
   _fx_N18Ast__interpolate_t interp_1 = *interp_0;
   for (;;) {
      _fx_N10Ast__exp_t arr_2 = 0;
      FX_COPY_PTR(arr_1, &arr_2);
      _fx_N13Ast__border_t border_2 = border_1;
      _fx_N18Ast__interpolate_t interp_2 = interp_1;
      if (FX_REC_VARIANT_TAG(arr_2) == 21) {
         _fx_T3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tR10Ast__loc_t* vcase_0 = &arr_2->u.ExpMem;
         _fx_N10Ast__exp_t v_0 = vcase_0->t1;
         if (FX_REC_VARIANT_TAG(v_0) == 7) {
            fx_str_t istr_0 = {0};
            FX_CALL(_fx_M3AstFM6stringS1RM4id_t(&v_0->u.ExpIdent.t0, &istr_0, 0), _fx_catch_3);
            _fx_N13Ast__border_t new_border_0;
            fx_str_t slit_0 = FX_MAKE_STR("clip");
            if (fx_streq(&istr_0, &slit_0)) {
               new_border_0 = _fx_g25Ast_typecheck__BorderClip; goto _fx_endmatch_0;
            }
            fx_str_t slit_1 = FX_MAKE_STR("wrap");
            if (fx_streq(&istr_0, &slit_1)) {
               new_border_0 = _fx_g25Ast_typecheck__BorderWrap; goto _fx_endmatch_0;
            }
            fx_str_t slit_2 = FX_MAKE_STR("zero");
            if (fx_streq(&istr_0, &slit_2)) {
               new_border_0 = _fx_g25Ast_typecheck__BorderZero; goto _fx_endmatch_0;
            }
            new_border_0 = _fx_g25Ast_typecheck__BorderNone;

         _fx_endmatch_0: ;
            FX_CHECK_EXN(_fx_catch_3);
            _fx_N13Ast__border_t border_3;
            if (new_border_0.tag == 1) {
               border_3 = border_2;
            }
            else if (border_2.tag == 1) {
               border_3 = new_border_0;
            }
            else {
               fx_str_t v_1 = {0};
               fx_str_t v_2 = {0};
               fx_str_t v_3 = {0};
               fx_exn_t v_4 = {0};
               FX_CALL(_fx_M3AstFM10border2strS2N13Ast__border_tB(&border_2, false, &v_1, 0), _fx_catch_0);
               FX_CALL(_fx_M3AstFM10border2strS2N13Ast__border_tB(&new_border_0, false, &v_2, 0), _fx_catch_0);
               fx_str_t slit_3 = FX_MAKE_STR("border was specified more than once: \'");
               fx_str_t slit_4 = FX_MAKE_STR("\' and \'");
               fx_str_t slit_5 = FX_MAKE_STR("\'");
               {
                  const fx_str_t strs_0[] = { slit_3, v_1, slit_4, v_2, slit_5 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_0, 5, &v_3), _fx_catch_0);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_3, &v_4, 0), _fx_catch_0);
               FX_THROW(&v_4, false, _fx_catch_0);

            _fx_catch_0: ;
               fx_free_exn(&v_4);
               FX_FREE_STR(&v_3);
               FX_FREE_STR(&v_2);
               FX_FREE_STR(&v_1);
            }
            FX_CHECK_EXN(_fx_catch_3);
            _fx_N18Ast__interpolate_t new_interp_0;
            fx_str_t slit_6 = FX_MAKE_STR("linear");
            if (fx_streq(&istr_0, &slit_6)) {
               new_interp_0 = _fx_g27Ast_typecheck__InterpLinear; goto _fx_endmatch_1;
            }
            new_interp_0 = _fx_g25Ast_typecheck__InterpNone;

         _fx_endmatch_1: ;
            FX_CHECK_EXN(_fx_catch_3);
            _fx_N18Ast__interpolate_t interp_3;
            if (new_interp_0.tag == 1) {
               interp_3 = interp_2;
            }
            else if (interp_2.tag == 1) {
               interp_3 = new_interp_0;
            }
            else {
               fx_exn_t v_5 = {0};
               fx_str_t slit_7 = FX_MAKE_STR("interpolation was specified more than once");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &slit_7, &v_5, 0), _fx_catch_1);
               FX_THROW(&v_5, false, _fx_catch_1);

            _fx_catch_1: ;
               fx_free_exn(&v_5);
            }
            FX_CHECK_EXN(_fx_catch_3);
            if (new_border_0.tag == 1) {
               if (new_interp_0.tag == 1) {
                  _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t result_1 = {0};
                  _fx_make_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(arr_2, &border_3, &interp_3, &result_1);
                  _fx_free_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&result_0);
                  _fx_copy_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&result_1, &result_0);
                  FX_BREAK(_fx_catch_2);

               _fx_catch_2: ;
                  _fx_free_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&result_1);
                  goto _fx_endmatch_2;
               }
            }
            _fx_N10Ast__exp_t* arr__0 = &vcase_0->t0;
            _fx_free_N10Ast__exp_t(&arr_1);
            FX_COPY_PTR(*arr__0, &arr_1);
            border_1 = border_3;
            interp_1 = interp_3;

         _fx_endmatch_2: ;
            FX_CHECK_EXN(_fx_catch_3);

         _fx_catch_3: ;
            FX_FREE_STR(&istr_0);
            goto _fx_endmatch_3;
         }
      }
      _fx_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t result_2 = {0};
      _fx_make_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(arr_2, &border_2, &interp_2, &result_2);
      _fx_free_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&result_0);
      _fx_copy_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&result_2, &result_0);
      FX_BREAK(_fx_catch_4);

   _fx_catch_4: ;
      _fx_free_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&result_2);

   _fx_endmatch_3: ;
      FX_CHECK_EXN(_fx_catch_5);

   _fx_catch_5: ;
      if (arr_2) {
         _fx_free_N10Ast__exp_t(&arr_2);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&result_0, fx_result);

_fx_cleanup: ;
   _fx_free_T3N10Ast__exp_tN13Ast__border_tN18Ast__interpolate_t(&result_0);
   if (arr_1) {
      _fx_free_N10Ast__exp_t(&arr_1);
   }
   return fx_status;
}

static int _fx_M13Ast_typecheckFM26idx_type_is_correct_scalarB4N10Ast__typ_tR10Ast__loc_tN18Ast__interpolate_tLN10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* idxtyp_0,
   struct _fx_R10Ast__loc_t* idxloc_0,
   struct _fx_N18Ast__interpolate_t* interp_0,
   struct _fx_LN10Ast__typ_t_data_t* possible_idx_typs_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t v_0 = 0;
   _fx_N10Ast__typ_t v_1 = 0;
   int fx_status = 0;
   bool __fold_result___0 = false;
   _fx_LN10Ast__typ_t lst_0 = possible_idx_typs_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__typ_t t_0 = lst_0->hd;
      bool v_2;
      FX_CALL(
         _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(idxtyp_0, t_0, idxloc_0, true, &v_2, 0),
         _fx_catch_0);
      if (v_2) {
         __fold_result___0 = true; FX_BREAK(_fx_catch_0);
      }

   _fx_catch_0: ;
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   if (__fold_result___0) {
      *fx_result = true;
   }
   else if (interp_0->tag == 2) {
      FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(32, &v_0), _fx_cleanup);
      bool res_0;
      FX_CALL(
         _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(idxtyp_0, v_0, idxloc_0, true, &res_0,
            0), _fx_cleanup);
      if (res_0) {
         *fx_result = true;
      }
      else {
         FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(64, &v_1), _fx_cleanup);
         FX_CALL(
            _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(idxtyp_0, v_1, idxloc_0, true,
               fx_result, 0), _fx_cleanup);
      }
   }
   else {
      *fx_result = false;
   }

_fx_cleanup: ;
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   if (v_1) {
      _fx_free_N10Ast__typ_t(&v_1);
   }
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM25idx_type_is_correct_tupleT2Bi5N10Ast__typ_tR10Ast__loc_tLN10Ast__exp_tN18Ast__interpolate_tLN10Ast__typ_t(
   struct _fx_N10Ast__typ_t_data_t* idxtyp_0,
   struct _fx_R10Ast__loc_t* tuploc_0,
   struct _fx_LN10Ast__exp_t_data_t* idxs_0,
   struct _fx_N18Ast__interpolate_t* interp_0,
   struct _fx_LN10Ast__typ_t_data_t* possible_idx_typs_0,
   struct _fx_T2Bi* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t v_0 = 0;
   int fx_status = 0;
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(idxtyp_0, &v_0, 0), _fx_cleanup);
   if (FX_REC_VARIANT_TAG(v_0) == 17) {
      fx_exn_t v_1 = {0};
      _fx_LN10Ast__typ_t idxtyplst_0 = 0;
      _fx_LN10Ast__typ_t idxtyplst_1 = v_0->u.TypTuple;
      int_ v_2 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__exp_t(idxs_0, 0);
      if (v_2 != 1) {
         fx_str_t slit_0 = FX_MAKE_STR("tuple index in array access op must be the only index");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(tuploc_0, &slit_0, &v_1, 0), _fx_catch_2);
         FX_THROW(&v_1, false, _fx_catch_2);
      }
      bool __fold_result___0 = true;
      FX_COPY_PTR(idxtyplst_1, &idxtyplst_0);
      _fx_LN10Ast__typ_t lst_0 = idxtyplst_0;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_N10Ast__typ_t v_3 = 0;
         _fx_N10Ast__typ_t v_4 = 0;
         _fx_N10Ast__typ_t a_0 = lst_0->hd;
         bool __fold_result___1 = false;
         _fx_LN10Ast__typ_t lst_1 = possible_idx_typs_0;
         for (; lst_1; lst_1 = lst_1->tl) {
            _fx_N10Ast__typ_t t_0 = lst_1->hd;
            bool v_5;
            FX_CALL(
               _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(a_0, t_0, tuploc_0, true, &v_5, 0),
               _fx_catch_0);
            if (v_5) {
               __fold_result___1 = true; FX_BREAK(_fx_catch_0);
            }

         _fx_catch_0: ;
            FX_CHECK_BREAK();
            FX_CHECK_EXN(_fx_catch_1);
         }
         bool v_6;
         if (__fold_result___1) {
            v_6 = true;
         }
         else if (interp_0->tag == 2) {
            FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(32, &v_3), _fx_catch_1);
            bool res_0;
            FX_CALL(
               _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(a_0, v_3, tuploc_0, true, &res_0,
                  0), _fx_catch_1);
            if (res_0) {
               v_6 = true;
            }
            else {
               FX_CALL(_fx_M3AstFM8TypFloatN10Ast__typ_t1i(64, &v_4), _fx_catch_1);
               FX_CALL(
                  _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(a_0, v_4, tuploc_0, true, &v_6,
                     0), _fx_catch_1);
            }
         }
         else {
            v_6 = false;
         }
         if (!v_6) {
            __fold_result___0 = false; FX_BREAK(_fx_catch_1);
         }

      _fx_catch_1: ;
         if (v_4) {
            _fx_free_N10Ast__typ_t(&v_4);
         }
         if (v_3) {
            _fx_free_N10Ast__typ_t(&v_3);
         }
         FX_CHECK_BREAK();
         FX_CHECK_EXN(_fx_catch_2);
      }
      bool iscorrect_0 = __fold_result___0;
      int_ v_7;
      if (iscorrect_0) {
         v_7 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(idxtyplst_1, 0);
      }
      else {
         v_7 = 0;
      }
      _fx_T2Bi tup_0 = { iscorrect_0, v_7 };
      *fx_result = tup_0;

   _fx_catch_2: ;
      if (idxtyplst_0) {
         _fx_free_LN10Ast__typ_t(&idxtyplst_0);
      }
      fx_free_exn(&v_1);
   }
   else {
      _fx_T2Bi tup_1 = { false, 0 }; *fx_result = tup_1;
   }

_fx_cleanup: ;
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   return fx_status;
}

static int _fx_M13Ast_typecheckFM13check_map_typv7N10Ast__typ_tN10Ast__typ_tiR10Ast__loc_tBBi(
   struct _fx_N10Ast__typ_t_data_t* elem_typ_0,
   struct _fx_N10Ast__typ_t_data_t* coll_typ_0,
   int_ idx_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   bool make_list_0,
   bool make_vector_0,
   int_ total_dims_0,
   void* fx_fv)
{
   fx_str_t idx_str_0 = {0};
   fx_str_t v_0 = {0};
   _fx_N10Ast__typ_t v_1 = 0;
   _fx_N10Ast__typ_t v_2 = 0;
   fx_str_t v_3 = {0};
   fx_str_t v_4 = {0};
   fx_str_t v_5 = {0};
   fx_exn_t v_6 = {0};
   _fx_N10Ast__typ_t v_7 = 0;
   _fx_N10Ast__typ_t v_8 = 0;
   fx_str_t v_9 = {0};
   fx_str_t v_10 = {0};
   fx_str_t v_11 = {0};
   fx_exn_t v_12 = {0};
   _fx_N10Ast__typ_t v_13 = 0;
   _fx_N10Ast__typ_t v_14 = 0;
   fx_str_t v_15 = {0};
   fx_str_t v_16 = {0};
   fx_str_t v_17 = {0};
   fx_exn_t v_18 = {0};
   int fx_status = 0;
   if (idx_0 < 0) {
      fx_str_t slit_0 = FX_MAKE_STR("of comprehension"); fx_copy_str(&slit_0, &idx_str_0);
   }
   else {
      FX_CALL(_fx_F6stringS1i(idx_0, &v_0, 0), _fx_cleanup);
      fx_str_t slit_1 = FX_MAKE_STR("#");
      fx_str_t slit_2 = FX_MAKE_STR(" (0-based) of @unzip comprehension");
      {
         const fx_str_t strs_0[] = { slit_1, v_0, slit_2 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &idx_str_0), _fx_cleanup);
      }
   }
   if (make_list_0) {
      FX_CALL(_fx_M3AstFM7TypListN10Ast__typ_t1N10Ast__typ_t(elem_typ_0, &v_1), _fx_cleanup);
      FX_CALL(_fx_M3AstFM7TypListN10Ast__typ_t1N10Ast__typ_t(elem_typ_0, &v_2), _fx_cleanup);
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(v_2, &v_3, 0), _fx_cleanup);
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(coll_typ_0, &v_4, 0), _fx_cleanup);
      fx_str_t slit_3 = FX_MAKE_STR("the result ");
      fx_str_t slit_4 = FX_MAKE_STR(" should have type \'");
      fx_str_t slit_5 = FX_MAKE_STR("\', but it has type \'");
      fx_str_t slit_6 = FX_MAKE_STR("\'");
      {
         const fx_str_t strs_1[] = { slit_3, idx_str_0, slit_4, v_3, slit_5, v_4, slit_6 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_1, 7, &v_5), _fx_cleanup);
      }
      bool v_19;
      FX_CALL(
         _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(coll_typ_0, v_1, eloc_0, true, &v_19, 0),
         _fx_cleanup);
      if (!v_19) {
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_5, &v_6, 0), _fx_cleanup); FX_THROW(&v_6, false, _fx_cleanup);
      }
   }
   else if (make_vector_0) {
      FX_CALL(_fx_M3AstFM9TypVectorN10Ast__typ_t1N10Ast__typ_t(elem_typ_0, &v_7), _fx_cleanup);
      FX_CALL(_fx_M3AstFM9TypVectorN10Ast__typ_t1N10Ast__typ_t(elem_typ_0, &v_8), _fx_cleanup);
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(v_8, &v_9, 0), _fx_cleanup);
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(coll_typ_0, &v_10, 0), _fx_cleanup);
      fx_str_t slit_7 = FX_MAKE_STR("the result ");
      fx_str_t slit_8 = FX_MAKE_STR(" should have type \'");
      fx_str_t slit_9 = FX_MAKE_STR("\', but it has type \'");
      fx_str_t slit_10 = FX_MAKE_STR("\'");
      {
         const fx_str_t strs_2[] = { slit_7, idx_str_0, slit_8, v_9, slit_9, v_10, slit_10 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_2, 7, &v_11), _fx_cleanup);
      }
      bool v_20;
      FX_CALL(
         _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(coll_typ_0, v_7, eloc_0, true, &v_20, 0),
         _fx_cleanup);
      if (!v_20) {
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_11, &v_12, 0), _fx_cleanup);
         FX_THROW(&v_12, false, _fx_cleanup);
      }
   }
   else {
      FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(total_dims_0, elem_typ_0, &v_13), _fx_cleanup);
      FX_CALL(_fx_M3AstFM8TypArrayN10Ast__typ_t2iN10Ast__typ_t(total_dims_0, elem_typ_0, &v_14), _fx_cleanup);
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(v_14, &v_15, 0), _fx_cleanup);
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(coll_typ_0, &v_16, 0), _fx_cleanup);
      fx_str_t slit_11 = FX_MAKE_STR("the result ");
      fx_str_t slit_12 = FX_MAKE_STR(" should have type \'");
      fx_str_t slit_13 = FX_MAKE_STR("\', but it has type \'");
      fx_str_t slit_14 = FX_MAKE_STR("\'");
      {
         const fx_str_t strs_3[] = { slit_11, idx_str_0, slit_12, v_15, slit_13, v_16, slit_14 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_3, 7, &v_17), _fx_cleanup);
      }
      bool v_21;
      FX_CALL(
         _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(coll_typ_0, v_13, eloc_0, true, &v_21,
            0), _fx_cleanup);
      if (!v_21) {
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_17, &v_18, 0), _fx_cleanup);
         FX_THROW(&v_18, false, _fx_cleanup);
      }
   }

_fx_cleanup: ;
   FX_FREE_STR(&idx_str_0);
   FX_FREE_STR(&v_0);
   if (v_1) {
      _fx_free_N10Ast__typ_t(&v_1);
   }
   if (v_2) {
      _fx_free_N10Ast__typ_t(&v_2);
   }
   FX_FREE_STR(&v_3);
   FX_FREE_STR(&v_4);
   FX_FREE_STR(&v_5);
   fx_free_exn(&v_6);
   if (v_7) {
      _fx_free_N10Ast__typ_t(&v_7);
   }
   if (v_8) {
      _fx_free_N10Ast__typ_t(&v_8);
   }
   FX_FREE_STR(&v_9);
   FX_FREE_STR(&v_10);
   FX_FREE_STR(&v_11);
   fx_free_exn(&v_12);
   if (v_13) {
      _fx_free_N10Ast__typ_t(&v_13);
   }
   if (v_14) {
      _fx_free_N10Ast__typ_t(&v_14);
   }
   FX_FREE_STR(&v_15);
   FX_FREE_STR(&v_16);
   FX_FREE_STR(&v_17);
   fx_free_exn(&v_18);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM12__lambda__1_B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
   struct _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* arg0_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM12__lambda__1_B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM12__lambda__1_B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_cldata_t*)fx_fv;
   _fx_R9Ast__id_t nj_0 = arg0_0->t1;
   FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&cv_0->t0, &nj_0, fx_result, 0), _fx_cleanup);

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM9make_fp1_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1R9Ast__id_t(
   struct _fx_R9Ast__id_t* arg0,
   struct _fx_FPB1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(
      _fx_M13Ast_typecheckFM12__lambda__1_B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t_cldata_t, fx_free,
      _fx_M13Ast_typecheckFM12__lambda__1_B1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t);
   fcv->t0 = *arg0;
   return 0;
}

static int _fx_M13Ast_typecheckFM9make_castN10Ast__exp_t4N10Ast__exp_tN10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__exp_t_data_t* e1_0,
   struct _fx_N10Ast__typ_t_data_t* t1_0,
   struct _fx_N10Ast__typ_t_data_t* t2_0,
   struct _fx_R10Ast__loc_t* eloc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t v_0 = 0;
   _fx_N10Ast__typ_t v_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   bool v_2;
   bool res_0;
   FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(t1_0, &res_0, 0), _fx_cleanup);
   if (res_0) {
      FX_CALL(_fx_M3AstFM13is_typ_scalarB1N10Ast__typ_t(t2_0, &v_2, 0), _fx_cleanup);
   }
   else {
      v_2 = false;
   }
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t1_0, &v_0, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t2_0, &v_1, 0), _fx_cleanup);
   if (v_2 == true) {
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_3 = {0};
      _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_0, eloc_0, &v_3);
      FX_CALL(_fx_M3AstFM7ExpCastN10Ast__exp_t3N10Ast__exp_tN10Ast__typ_tT2N10Ast__typ_tRM5loc_t(e1_0, t2_0, &v_3, fx_result),
         _fx_catch_0);

   _fx_catch_0: ;
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_3);
      goto _fx_endmatch_0;
   }
   if (FX_REC_VARIANT_TAG(e1_0) == 6) {
      if (FX_REC_VARIANT_TAG(v_1) == 15) {
         _fx_N10Ast__lit_t* v_4 = &e1_0->u.ExpLit.t0;
         if (v_4->tag == 1) {
            if (v_4->u.LitInt == 0LL) {
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_5 = {0};
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_0, eloc_0, &v_5);
               FX_CALL(
                  _fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&_fx_g23Ast_typecheck__LitEmpty, &v_5,
                     fx_result), _fx_catch_1);

            _fx_catch_1: ;
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_5);
               goto _fx_endmatch_0;
            }
         }
      }
   }
   if (FX_REC_VARIANT_TAG(e1_0) == 6) {
      if (FX_REC_VARIANT_TAG(v_1) == 10) {
         _fx_N10Ast__lit_t* v_6 = &e1_0->u.ExpLit.t0;
         if (v_6->tag == 1) {
            if (v_6->u.LitInt == 0LL) {
               _fx_N10Ast__lit_t v_7 = {0};
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_8 = {0};
               fx_str_t slit_0 = FX_MAKE_STR("");
               _fx_M3AstFM9LitStringN10Ast__lit_t1S(&slit_0, &v_7);
               _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_0, eloc_0, &v_8);
               FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_7, &v_8, fx_result),
                  _fx_catch_2);

            _fx_catch_2: ;
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_8);
               _fx_free_N10Ast__lit_t(&v_7);
               goto _fx_endmatch_0;
            }
         }
      }
   }
   if (FX_REC_VARIANT_TAG(v_1) == 17) {
      if (FX_REC_VARIANT_TAG(v_0) == 17) {
         fx_str_t v_9 = {0};
         fx_str_t v_10 = {0};
         fx_str_t v_11 = {0};
         fx_exn_t v_12 = {0};
         _fx_LN10Ast__exp_t el_0 = 0;
         _fx_LN10Ast__typ_t tl1_0 = 0;
         _fx_LN10Ast__typ_t tl2_0 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_13 = {0};
         _fx_LN10Ast__typ_t tl1_1 = v_0->u.TypTuple;
         _fx_LN10Ast__typ_t tl2_1 = v_1->u.TypTuple;
         int_ n1_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(tl1_1, 0);
         int_ n2_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(tl2_1, 0);
         if (n1_0 != n2_0) {
            FX_CALL(_fx_F6stringS1i(n1_0, &v_9, 0), _fx_catch_4);
            FX_CALL(_fx_F6stringS1i(n2_0, &v_10, 0), _fx_catch_4);
            fx_str_t slit_1 = FX_MAKE_STR("the number of elements in the source tuple type (");
            fx_str_t slit_2 = FX_MAKE_STR(") and the destination tuple type (");
            fx_str_t slit_3 = FX_MAKE_STR(") do not match");
            {
               const fx_str_t strs_0[] = { slit_1, v_9, slit_2, v_10, slit_3 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_0, 5, &v_11), _fx_catch_4);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_11, &v_12, 0), _fx_catch_4);
            FX_THROW(&v_12, false, _fx_catch_4);
         }
         _fx_LN10Ast__exp_t lstend_0 = 0;
         int_ i_0 = 0;
         FX_COPY_PTR(tl1_1, &tl1_0);
         _fx_LN10Ast__typ_t lst_0 = tl1_0;
         FX_COPY_PTR(tl2_1, &tl2_0);
         _fx_LN10Ast__typ_t lst_1 = tl2_0;
         for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl, i_0 += 1) {
            _fx_N10Ast__lit_t v_14 = {0};
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_15 = {0};
            _fx_N10Ast__exp_t v_16 = 0;
            _fx_T2N10Ast__typ_tR10Ast__loc_t v_17 = {0};
            _fx_N10Ast__exp_t ei_0 = 0;
            _fx_N10Ast__exp_t res_1 = 0;
            _fx_N10Ast__typ_t t2_1 = lst_1->hd;
            _fx_N10Ast__typ_t t1_1 = lst_0->hd;
            _fx_M3AstFM6LitIntN10Ast__lit_t1l((int64_t)i_0, &v_14);
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, eloc_0, &v_15);
            FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_14, &v_15, &v_16), _fx_catch_3);
            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t1_1, eloc_0, &v_17);
            FX_CALL(_fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(e1_0, v_16, &v_17, &ei_0),
               _fx_catch_3);
            FX_CALL(
               _fx_M13Ast_typecheckFM9make_castN10Ast__exp_t4N10Ast__exp_tN10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(ei_0, t1_1,
                  t2_1, eloc_0, &res_1, 0), _fx_catch_3);
            _fx_LN10Ast__exp_t node_0 = 0;
            FX_CALL(_fx_cons_LN10Ast__exp_t(res_1, 0, false, &node_0), _fx_catch_3);
            FX_LIST_APPEND(el_0, lstend_0, node_0);

         _fx_catch_3: ;
            if (res_1) {
               _fx_free_N10Ast__exp_t(&res_1);
            }
            if (ei_0) {
               _fx_free_N10Ast__exp_t(&ei_0);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_17);
            if (v_16) {
               _fx_free_N10Ast__exp_t(&v_16);
            }
            _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_15);
            _fx_free_N10Ast__lit_t(&v_14);
            FX_CHECK_EXN(_fx_catch_4);
         }
         int s_0 = !lst_0 + !lst_1;
         FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_4);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_0, eloc_0, &v_13);
         FX_CALL(_fx_M3AstFM10ExpMkTupleN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(el_0, &v_13, fx_result),
            _fx_catch_4);

      _fx_catch_4: ;
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_13);
         if (tl2_0) {
            _fx_free_LN10Ast__typ_t(&tl2_0);
         }
         if (tl1_0) {
            _fx_free_LN10Ast__typ_t(&tl1_0);
         }
         if (el_0) {
            _fx_free_LN10Ast__exp_t(&el_0);
         }
         fx_free_exn(&v_12);
         FX_FREE_STR(&v_11);
         FX_FREE_STR(&v_10);
         FX_FREE_STR(&v_9);
         goto _fx_endmatch_0;
      }
   }
   if (FX_REC_VARIANT_TAG(v_0) == 17) {
      _fx_T2LN10Ast__exp_tLN10Ast__typ_t v_18 = {0};
      _fx_LN10Ast__exp_t lst_2 = 0;
      _fx_LN10Ast__typ_t lst_3 = 0;
      _fx_LN10Ast__typ_t tl1_2 = 0;
      _fx_LN10Ast__exp_t el_1 = 0;
      _fx_LN10Ast__typ_t tl2_2 = 0;
      _fx_N10Ast__typ_t v_19 = 0;
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_20 = {0};
      _fx_LN10Ast__exp_t lstend_1 = 0;
      _fx_LN10Ast__typ_t lstend_2 = 0;
      int_ i_1 = 0;
      FX_COPY_PTR(v_0->u.TypTuple, &tl1_2);
      _fx_LN10Ast__typ_t lst_4 = tl1_2;
      for (; lst_4; lst_4 = lst_4->tl, i_1 += 1) {
         _fx_N10Ast__lit_t v_21 = {0};
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_22 = {0};
         _fx_N10Ast__exp_t v_23 = 0;
         _fx_T2N10Ast__typ_tR10Ast__loc_t v_24 = {0};
         _fx_N10Ast__exp_t ei_1 = 0;
         _fx_N10Ast__exp_t ei_2 = 0;
         _fx_T2N10Ast__exp_tN10Ast__typ_t tup_0 = {0};
         _fx_N10Ast__typ_t t1_2 = lst_4->hd;
         _fx_M3AstFM6LitIntN10Ast__lit_t1l((int64_t)i_1, &v_21);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, eloc_0, &v_22);
         FX_CALL(_fx_M3AstFM6ExpLitN10Ast__exp_t2N10Ast__lit_tT2N10Ast__typ_tRM5loc_t(&v_21, &v_22, &v_23), _fx_catch_5);
         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t1_2, eloc_0, &v_24);
         FX_CALL(_fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(e1_0, v_23, &v_24, &ei_1),
            _fx_catch_5);
         FX_CALL(
            _fx_M13Ast_typecheckFM9make_castN10Ast__exp_t4N10Ast__exp_tN10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(ei_1, t1_2, t2_0,
               eloc_0, &ei_2, 0), _fx_catch_5);
         _fx_make_T2N10Ast__exp_tN10Ast__typ_t(ei_2, t2_0, &tup_0);
         _fx_LN10Ast__exp_t node_1 = 0;
         FX_CALL(_fx_cons_LN10Ast__exp_t(tup_0.t0, 0, false, &node_1), _fx_catch_5);
         FX_LIST_APPEND(lst_2, lstend_1, node_1);
         _fx_LN10Ast__typ_t node_2 = 0;
         FX_CALL(_fx_cons_LN10Ast__typ_t(tup_0.t1, 0, false, &node_2), _fx_catch_5);
         FX_LIST_APPEND(lst_3, lstend_2, node_2);

      _fx_catch_5: ;
         _fx_free_T2N10Ast__exp_tN10Ast__typ_t(&tup_0);
         if (ei_2) {
            _fx_free_N10Ast__exp_t(&ei_2);
         }
         if (ei_1) {
            _fx_free_N10Ast__exp_t(&ei_1);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_24);
         if (v_23) {
            _fx_free_N10Ast__exp_t(&v_23);
         }
         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_22);
         _fx_free_N10Ast__lit_t(&v_21);
         FX_CHECK_EXN(_fx_catch_6);
      }
      _fx_make_T2LN10Ast__exp_tLN10Ast__typ_t(lst_2, lst_3, &v_18);
      FX_COPY_PTR(v_18.t0, &el_1);
      FX_COPY_PTR(v_18.t1, &tl2_2);
      FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(tl2_2, &v_19), _fx_catch_6);
      _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_19, eloc_0, &v_20);
      FX_CALL(_fx_M3AstFM10ExpMkTupleN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(el_1, &v_20, fx_result), _fx_catch_6);

   _fx_catch_6: ;
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_20);
      if (v_19) {
         _fx_free_N10Ast__typ_t(&v_19);
      }
      if (tl2_2) {
         _fx_free_LN10Ast__typ_t(&tl2_2);
      }
      if (el_1) {
         _fx_free_LN10Ast__exp_t(&el_1);
      }
      if (tl1_2) {
         _fx_free_LN10Ast__typ_t(&tl1_2);
      }
      if (lst_3) {
         _fx_free_LN10Ast__typ_t(&lst_3);
      }
      if (lst_2) {
         _fx_free_LN10Ast__exp_t(&lst_2);
      }
      _fx_free_T2LN10Ast__exp_tLN10Ast__typ_t(&v_18);
      goto _fx_endmatch_0;
   }
   if (FX_REC_VARIANT_TAG(v_1) == 17) {
      _fx_LN10Ast__exp_t v_25 = 0;
      _fx_LN10Ast__typ_t tl2_3 = 0;
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_26 = {0};
      _fx_LN10Ast__exp_t lstend_3 = 0;
      FX_COPY_PTR(v_1->u.TypTuple, &tl2_3);
      _fx_LN10Ast__typ_t lst_5 = tl2_3;
      for (; lst_5; lst_5 = lst_5->tl) {
         _fx_N10Ast__exp_t res_2 = 0;
         _fx_N10Ast__typ_t t2_2 = lst_5->hd;
         FX_CALL(
            _fx_M13Ast_typecheckFM9make_castN10Ast__exp_t4N10Ast__exp_tN10Ast__typ_tN10Ast__typ_tR10Ast__loc_t(e1_0, t1_0, t2_2,
               eloc_0, &res_2, 0), _fx_catch_7);
         _fx_LN10Ast__exp_t node_3 = 0;
         FX_CALL(_fx_cons_LN10Ast__exp_t(res_2, 0, false, &node_3), _fx_catch_7);
         FX_LIST_APPEND(v_25, lstend_3, node_3);

      _fx_catch_7: ;
         if (res_2) {
            _fx_free_N10Ast__exp_t(&res_2);
         }
         FX_CHECK_EXN(_fx_catch_8);
      }
      _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t2_0, eloc_0, &v_26);
      FX_CALL(_fx_M3AstFM10ExpMkTupleN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(v_25, &v_26, fx_result), _fx_catch_8);

   _fx_catch_8: ;
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_26);
      if (tl2_3) {
         _fx_free_LN10Ast__typ_t(&tl2_3);
      }
      if (v_25) {
         _fx_free_LN10Ast__exp_t(&v_25);
      }
      goto _fx_endmatch_0;
   }
   fx_str_t v_27 = {0};
   fx_str_t v_28 = {0};
   fx_str_t v_29 = {0};
   fx_exn_t v_30 = {0};
   FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t1_0, &v_27, 0), _fx_catch_9);
   FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(t2_0, &v_28, 0), _fx_catch_9);
   fx_str_t slit_4 = FX_MAKE_STR("invalid cast operation: \'");
   fx_str_t slit_5 = FX_MAKE_STR("\' to \'");
   fx_str_t slit_6 = FX_MAKE_STR("\'");
   {
      const fx_str_t strs_1[] = { slit_4, v_27, slit_5, v_28, slit_6 };
      FX_CALL(fx_strjoin(0, 0, 0, strs_1, 5, &v_29), _fx_catch_9);
   }
   FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_29, &v_30, 0), _fx_catch_9);
   FX_THROW(&v_30, false, _fx_catch_9);

_fx_catch_9: ;
   fx_free_exn(&v_30);
   FX_FREE_STR(&v_29);
   FX_FREE_STR(&v_28);
   FX_FREE_STR(&v_27);

_fx_endmatch_0: ;

_fx_cleanup: ;
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   if (v_1) {
      _fx_free_N10Ast__typ_t(&v_1);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM10check_eseqT2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tB(
   struct _fx_LN10Ast__exp_t_data_t* eseq_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool create_sc_0,
   struct _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_LN12Ast__scope_t sc_1 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_4 = {0};
   _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___1 = {0};
   _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_0 = {0};
   _fx_LN10Ast__exp_t eseq_1 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_5 = {0};
   _fx_LN10Ast__exp_t __fold_result___2 = 0;
   _fx_LN10Ast__exp_t v_1 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   bool is_func_scope_0;
   if (sc_0 != 0) {
      if (sc_0->hd.tag == 7) {
         is_func_scope_0 = true; goto _fx_endmatch_0;
      }
   }
   is_func_scope_0 = false;

_fx_endmatch_0: ;
   FX_CHECK_EXN(_fx_cleanup);
   if (create_sc_0) {
      _fx_N12Ast__scope_t v_2;
      FX_CALL(_fx_M3AstFM15new_block_scopeN12Ast__scope_t1i(curr_m_idx_0, &v_2, 0), _fx_cleanup);
      FX_CALL(_fx_cons_LN12Ast__scope_t(&v_2, sc_0, true, &sc_1), _fx_cleanup);
   }
   else {
      FX_COPY_PTR(sc_0, &sc_1);
   }
   bool is_glob_scope_0;
   FX_CALL(_fx_M3AstFM15is_global_scopeB1LN12Ast__scope_t(sc_1, &is_glob_scope_0, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM16check_directivesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
         eseq_0, env_0, sc_1, &env_1, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM9reg_typesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
         eseq_0, &env_1, sc_1, &env_2, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM11check_typesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
         eseq_0, &env_2, sc_1, &env_3, 0), _fx_cleanup);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3, &__fold_result___0);
   _fx_LN10Ast__exp_t lst_0 = eseq_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_6 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_3 = {0};
      _fx_N10Ast__exp_t e_0 = lst_0->hd;
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_6);
      int tag_0 = FX_REC_VARIANT_TAG(e_0);
      if (tag_0 == 35) {
         FX_CALL(
            _fx_M13Ast_typecheckFM10reg_deffunRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3rR13Ast__deffun_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e_0->u.DefFun, &env_6, sc_1, &v_3, 0), _fx_catch_0);

      _fx_catch_0: ;
      }
      else if (tag_0 == 36) {
         FX_CALL(
            _fx_M13Ast_typecheckFM12check_defexnRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3rR13Ast__defexn_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e_0->u.DefExn, &env_6, sc_1, &v_3, 0), _fx_catch_1);

      _fx_catch_1: ;
      }
      else {
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_6, &v_3);
      }
      FX_CHECK_EXN(_fx_catch_2);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_3, &__fold_result___0);

   _fx_catch_2: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_3);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_6);
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_4);
   int_ nexps_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__exp_t(eseq_0, 0);
   _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(0, &env_4, &__fold_result___1);
   int_ idx_0 = 0;
   _fx_LN10Ast__exp_t lst_1 = eseq_0;
   for (; lst_1; lst_1 = lst_1->tl, idx_0 += 1) {
      _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_4 = {0};
      _fx_LN10Ast__exp_t eseq_2 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_7 = {0};
      _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_5 = {0};
      fx_exn_t exn_0 = {0};
      _fx_LN10Ast__exp_t eseq1_0 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_0 = {0};
      _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_6 = {0};
      _fx_N10Ast__exp_t e_1 = lst_1->hd;
      _fx_copy_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1, &v_4);
      FX_COPY_PTR(v_4.t0, &eseq_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_4.t1, &env_7);
      int tag_1 = FX_REC_VARIANT_TAG(e_1);
      bool res_0;
      if (tag_1 == 40) {
         res_0 = true;
      }
      else if (tag_1 == 41) {
         res_0 = true;
      }
      else if (tag_1 == 42) {
         res_0 = true;
      }
      else if (tag_1 == 37) {
         res_0 = true;
      }
      else if (tag_1 == 38) {
         res_0 = true;
      }
      else if (tag_1 == 39) {
         res_0 = true;
      }
      else if (tag_1 == 36) {
         res_0 = true;
      }
      else {
         res_0 = false;
      }
      FX_CHECK_EXN(_fx_catch_16);
      if (res_0) {
         fx_exn_t v_7 = {0};
         _fx_LN10Ast__exp_t v_8 = 0;
         bool t_0;
         if (idx_0 == nexps_0 - 1) {
            t_0 = !is_glob_scope_0;
         }
         else {
            t_0 = false;
         }
         if (t_0) {
            _fx_R10Ast__loc_t v_9;
            FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(e_1, &v_9, 0), _fx_catch_3);
            fx_str_t slit_0 = FX_MAKE_STR("definition or directive occurs in the end of block; put some expression after it");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&v_9, &slit_0, &v_7, 0), _fx_catch_3);
            FX_THROW(&v_7, false, _fx_catch_3);
         }
         FX_CALL(_fx_cons_LN10Ast__exp_t(e_1, eseq_2, true, &v_8), _fx_catch_3);
         _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_8, &env_7, &v_5);

      _fx_catch_3: ;
         if (v_8) {
            _fx_free_LN10Ast__exp_t(&v_8);
         }
         fx_free_exn(&v_7);
         goto _fx_endmatch_4;
      }
      if (tag_1 == 34) {
         fx_exn_t v_10 = {0};
         _fx_N10Ast__typ_t t_1 = 0;
         _fx_T2N10Ast__pat_tN10Ast__typ_t v_11 = {0};
         _fx_N10Ast__pat_t p_0 = 0;
         _fx_N10Ast__typ_t t1_0 = 0;
         fx_exn_t exn_1 = {0};
         _fx_T4N10Ast__pat_tN10Ast__exp_tR16Ast__val_flags_tR10Ast__loc_t* vcase_0 = &e_1->u.DefVal;
         _fx_R10Ast__loc_t* loc_0 = &vcase_0->t3;
         _fx_R16Ast__val_flags_t* flags_0 = &vcase_0->t2;
         _fx_N10Ast__exp_t e_2 = vcase_0->t1;
         _fx_N10Ast__pat_t p_1 = vcase_0->t0;
         bool t_2;
         if (idx_0 == nexps_0 - 1) {
            t_2 = !is_glob_scope_0;
         }
         else {
            t_2 = false;
         }
         if (t_2) {
            fx_str_t slit_1 = FX_MAKE_STR("value definition occurs in the end of block; put some expression after it");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_1, &v_10, 0), _fx_catch_9);
            FX_THROW(&v_10, false, _fx_catch_9);
         }
         bool is_mutable_0 = flags_0->val_flag_mutable;
         FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(e_2, &t_1, 0), _fx_catch_9);
         if (FX_REC_VARIANT_TAG(p_1) == 9) {
            _fx_N10Ast__typ_t t1_1 = 0;
            fx_exn_t v_12 = {0};
            _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t* vcase_1 = &p_1->u.PatTyped;
            _fx_R10Ast__loc_t* loc_1 = &vcase_1->t2;
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  vcase_1->t1, &env_7, sc_1, loc_1, &t1_1, 0), _fx_catch_4);
            bool v_13;
            FX_CALL(
               _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t_1, t1_1, loc_1, true, &v_13, 0),
               _fx_catch_4);
            if (!v_13) {
               fx_str_t slit_2 =
                  FX_MAKE_STR("explicit type specification of the defined value does not match the assigned expression type");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_1, &slit_2, &v_12, 0), _fx_catch_4);
               FX_THROW(&v_12, false, _fx_catch_4);
            }
            _fx_make_T2N10Ast__pat_tN10Ast__typ_t(vcase_1->t0, t1_1, &v_11);

         _fx_catch_4: ;
            fx_free_exn(&v_12);
            if (t1_1) {
               _fx_free_N10Ast__typ_t(&t1_1);
            }
         }
         else {
            _fx_make_T2N10Ast__pat_tN10Ast__typ_t(p_1, t_1, &v_11);
         }
         FX_CHECK_EXN(_fx_catch_9);
         FX_COPY_PTR(v_11.t0, &p_0);
         FX_COPY_PTR(v_11.t1, &t1_0);
         _fx_N10Ast__exp_t e1_0 = 0;
         _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_14 = {0};
         _fx_N10Ast__pat_t p1_0 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_1 = {0};
         _fx_N10Ast__exp_t v_15 = 0;
         _fx_LN10Ast__exp_t v_16 = 0;
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
               e_2, &env_7, sc_1, &e1_0, 0), _fx_catch_5);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
               p_0, t_1, &env_7, &_fx_g16Ast__empty_idset, &_fx_g16Ast__empty_idset, sc_1, false, true, is_mutable_0, &v_14, 0),
            _fx_catch_5);
         FX_COPY_PTR(v_14.t0, &p1_0);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_14.t1, &env1_1);
         FX_CALL(
            _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(p1_0, e1_0, flags_0, loc_0,
               &v_15), _fx_catch_5);
         FX_CALL(_fx_cons_LN10Ast__exp_t(v_15, eseq_2, true, &v_16), _fx_catch_5);
         _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_16, &env1_1, &v_5);

      _fx_catch_5: ;
         if (e1_0) {
            _fx_free_N10Ast__exp_t(&e1_0);
         }
         _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_14);
         if (p1_0) {
            _fx_free_N10Ast__pat_t(&p1_0);
         }
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_1);
         if (v_15) {
            _fx_free_N10Ast__exp_t(&v_15);
         }
         if (v_16) {
            _fx_free_LN10Ast__exp_t(&v_16);
         }
         if (fx_status < 0) {
            fx_exn_get_and_reset(fx_status, &exn_1);
            fx_status = 0;
            _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_5);
            if (exn_1.tag == _FX_EXN_E17Ast__CompileError) {
               _fx_N10Ast__pat_t v_17 = 0;
               FX_CALL(_fx_M3AstFM16push_compile_errv1E(&exn_1, 0), _fx_catch_8);
               FX_CALL(_fx_M3AstFM14pat_skip_typedN10Ast__pat_t1N10Ast__pat_t(p_0, &v_17, 0), _fx_catch_8);
               if (FX_REC_VARIANT_TAG(v_17) == 3) {
                  _fx_R13Ast__defval_t dv_0 = {0};
                  _fx_N14Ast__id_info_t v_18 = {0};
                  _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_2 = {0};
                  _fx_N10Ast__pat_t v_19 = 0;
                  _fx_N10Ast__pat_t v_20 = 0;
                  _fx_N10Ast__exp_t v_21 = 0;
                  _fx_LN10Ast__exp_t v_22 = 0;
                  _fx_T2R9Ast__id_tR10Ast__loc_t* vcase_2 = &v_17->u.PatIdent;
                  _fx_R10Ast__loc_t* ploc_0 = &vcase_2->t1;
                  _fx_R9Ast__id_t* n_0 = &vcase_2->t0;
                  _fx_R9Ast__id_t n1_0;
                  FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, n_0, &n1_0, 0), _fx_catch_6);
                  _fx_make_R13Ast__defval_t(&n1_0, t1_0, flags_0, sc_1, loc_0, &dv_0);
                  _fx_M3AstFM6IdDValN14Ast__id_info_t1RM8defval_t(&dv_0, &v_18);
                  FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&n1_0, &v_18, 0), _fx_catch_6);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
                        n_0, &n1_0, &env_7, &env1_2, 0), _fx_catch_6);
                  FX_CALL(_fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&n1_0, ploc_0, &v_19), _fx_catch_6);
                  FX_CALL(_fx_M3AstFM8PatTypedN10Ast__pat_t3N10Ast__pat_tN10Ast__typ_tRM5loc_t(v_19, t1_0, ploc_0, &v_20),
                     _fx_catch_6);
                  FX_CALL(
                     _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(v_20, e_2, flags_0,
                        loc_0, &v_21), _fx_catch_6);
                  FX_CALL(_fx_cons_LN10Ast__exp_t(v_21, eseq_2, true, &v_22), _fx_catch_6);
                  _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_22, &env1_2, &v_5);

               _fx_catch_6: ;
                  if (v_22) {
                     _fx_free_LN10Ast__exp_t(&v_22);
                  }
                  if (v_21) {
                     _fx_free_N10Ast__exp_t(&v_21);
                  }
                  if (v_20) {
                     _fx_free_N10Ast__pat_t(&v_20);
                  }
                  if (v_19) {
                     _fx_free_N10Ast__pat_t(&v_19);
                  }
                  _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_2);
                  _fx_free_N14Ast__id_info_t(&v_18);
                  _fx_free_R13Ast__defval_t(&dv_0);
               }
               else {
                  _fx_N10Ast__exp_t v_23 = 0;
                  _fx_LN10Ast__exp_t v_24 = 0;
                  FX_CALL(
                     _fx_M3AstFM6DefValN10Ast__exp_t4N10Ast__pat_tN10Ast__exp_tRM11val_flags_tRM5loc_t(p_0, e_2, flags_0, loc_0,
                        &v_23), _fx_catch_7);
                  FX_CALL(_fx_cons_LN10Ast__exp_t(v_23, eseq_2, true, &v_24), _fx_catch_7);
                  _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_24, &env_7, &v_5);

               _fx_catch_7: ;
                  if (v_24) {
                     _fx_free_LN10Ast__exp_t(&v_24);
                  }
                  if (v_23) {
                     _fx_free_N10Ast__exp_t(&v_23);
                  }
               }
               FX_CHECK_EXN(_fx_catch_8);

            _fx_catch_8: ;
               if (v_17) {
                  _fx_free_N10Ast__pat_t(&v_17);
               }
            }
            else {
               FX_RETHROW(&exn_1, _fx_catch_9);
            }
            FX_CHECK_EXN(_fx_catch_9);
         }

      _fx_catch_9: ;
         fx_free_exn(&exn_1);
         if (t1_0) {
            _fx_free_N10Ast__typ_t(&t1_0);
         }
         if (p_0) {
            _fx_free_N10Ast__pat_t(&p_0);
         }
         _fx_free_T2N10Ast__pat_tN10Ast__typ_t(&v_11);
         if (t_1) {
            _fx_free_N10Ast__typ_t(&t_1);
         }
         fx_free_exn(&v_10);
         goto _fx_endmatch_4;
      }
      if (tag_1 == 35) {
         fx_exn_t v_25 = {0};
         _fx_LR9Ast__id_t v_26 = 0;
         _fx_rR13Ast__deffun_t df_0 = 0;
         _fx_R13Ast__deffun_t v_27 = {0};
         _fx_N10Ast__exp_t v_28 = 0;
         _fx_LN10Ast__exp_t v_29 = 0;
         _fx_rR13Ast__deffun_t df_1 = e_1->u.DefFun;
         bool t_3;
         if (idx_0 == nexps_0 - 1) {
            t_3 = !is_glob_scope_0;
         }
         else {
            t_3 = false;
         }
         if (t_3) {
            _fx_R10Ast__loc_t v_30 = df_1->data.df_loc;
            fx_str_t slit_3 = FX_MAKE_STR("function definition occurs in the end of block; put some expression after it");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&v_30, &slit_3, &v_25, 0), _fx_catch_10);
            FX_THROW(&v_25, false, _fx_catch_10);
         }
         FX_COPY_PTR(df_1->data.df_templ_args, &v_26);
         if (v_26 == 0) {
            FX_CALL(
               _fx_M13Ast_typecheckFM12check_deffunrR13Ast__deffun_t2rR13Ast__deffun_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
                  df_1, &env_7, &df_0, 0), _fx_catch_10);
         }
         else {
            _fx_R13Ast__deffun_t* v_31 = &df_1->data;
            _fx_make_R13Ast__deffun_t(&v_31->df_name, v_31->df_templ_args, v_31->df_args, v_31->df_typ, v_31->df_body,
               &v_31->df_flags, v_31->df_scope, &v_31->df_loc, v_31->df_templ_inst, &env_7, &v_27);
            _fx_R13Ast__deffun_t* v_32 = &df_1->data;
            _fx_free_R13Ast__deffun_t(v_32);
            _fx_copy_R13Ast__deffun_t(&v_27, v_32);
            FX_COPY_PTR(df_1, &df_0);
         }
         FX_CALL(_fx_M3AstFM6DefFunN10Ast__exp_t1rRM8deffun_t(df_0, &v_28), _fx_catch_10);
         FX_CALL(_fx_cons_LN10Ast__exp_t(v_28, eseq_2, true, &v_29), _fx_catch_10);
         _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_29, &env_7, &v_5);

      _fx_catch_10: ;
         if (v_29) {
            _fx_free_LN10Ast__exp_t(&v_29);
         }
         if (v_28) {
            _fx_free_N10Ast__exp_t(&v_28);
         }
         _fx_free_R13Ast__deffun_t(&v_27);
         if (df_0) {
            _fx_free_rR13Ast__deffun_t(&df_0);
         }
         FX_FREE_LIST_SIMPLE(&v_26);
         fx_free_exn(&v_25);
         goto _fx_endmatch_4;
      }
      _fx_N10Ast__exp_t e_3 = 0;
      _fx_N10Ast__exp_t e_4 = 0;
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_33 = {0};
      _fx_N10Ast__typ_t etyp_0 = 0;
      _fx_LN10Ast__exp_t v_34 = 0;
      if (FX_REC_VARIANT_TAG(e_1) == 4) {
         _fx_Nt6option1N10Ast__exp_t v_35 = e_1->u.ExpReturn.t0;
         if ((v_35 != 0) + 1 == 2) {
            bool t_4;
            if (idx_0 == nexps_0 - 1) {
               t_4 = is_func_scope_0;
            }
            else {
               t_4 = false;
            }
            if (t_4) {
               FX_COPY_PTR(v_35->u.Some, &e_3);
            }
            else {
               FX_COPY_PTR(e_1, &e_3);
            }
            goto _fx_endmatch_1;
         }
      }
      FX_COPY_PTR(e_1, &e_3);

   _fx_endmatch_1: ;
      FX_CHECK_EXN(_fx_catch_15);
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
            e_3, &env_7, sc_1, &e_4, 0), _fx_catch_15);
      FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e_4, &v_33, 0), _fx_catch_15);
      FX_COPY_PTR(v_33.t0, &etyp_0);
      _fx_R10Ast__loc_t eloc_0 = v_33.t1;
      int tag_2 = FX_REC_VARIANT_TAG(e_4);
      if (tag_2 == 1) {
         fx_exn_t v_36 = {0};
         if (nexps_0 != 1) {
            fx_str_t slit_4 = FX_MAKE_STR("there cannot be {} operators inside code blocks");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_4, &v_36, 0), _fx_catch_11);
            FX_THROW(&v_36, false, _fx_catch_11);
         }

      _fx_catch_11: ;
         fx_free_exn(&v_36);
         goto _fx_endmatch_3;
      }
      bool res_1;
      if (tag_2 == 2) {
         res_1 = true;
      }
      else if (tag_2 == 3) {
         res_1 = true;
      }
      else if (tag_2 == 4) {
         res_1 = true;
      }
      else {
         res_1 = false;
      }
      FX_CHECK_EXN(_fx_catch_15);
      if (res_1) {
         fx_exn_t v_37 = {0};
         if (idx_0 != nexps_0 - 1) {
            fx_str_t slit_5 =
               FX_MAKE_STR(
                  "break/continue/return operator should not be followed by any other operators in the same linear code sequence");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_5, &v_37, 0), _fx_catch_12);
            FX_THROW(&v_37, false, _fx_catch_12);
         }

      _fx_catch_12: ;
         fx_free_exn(&v_37);
         goto _fx_endmatch_3;
      }
      if (tag_2 == 32) {
         goto _fx_endmatch_3;
      }
      _fx_N10Ast__typ_t v_38 = 0;
      _fx_Nt6option1N10Ast__typ_t v_39 = 0;
      FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(etyp_0, &v_38, 0), _fx_catch_14);
      int tag_3 = FX_REC_VARIANT_TAG(v_38);
      bool res_2;
      if (tag_3 == 13) {
         res_2 = true;
      }
      else if (tag_3 == 25) {
         res_2 = true;
      }
      else {
         res_2 = false;
      }
      FX_CHECK_EXN(_fx_catch_14);
      if (res_2) {
         goto _fx_endmatch_2;
      }
      if (tag_3 == 1) {
         FX_COPY_PTR(v_38->u.TypVar->data, &v_39);
         if ((v_39 != 0) + 1 == 1) {
            goto _fx_endmatch_2;
         }
      }
      fx_exn_t v_40 = {0};
      if (idx_0 != nexps_0 - 1) {
         fx_str_t slit_6 =
            FX_MAKE_STR(
               "non-void expression occurs before the end of code block. Check the line breaks; if it\'s valid, use ignore() function to dismiss the error");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&eloc_0, &slit_6, &v_40, 0), _fx_catch_13);
         FX_THROW(&v_40, false, _fx_catch_13);
      }

   _fx_catch_13: ;
      fx_free_exn(&v_40);

   _fx_endmatch_2: ;
      FX_CHECK_EXN(_fx_catch_14);

   _fx_catch_14: ;
      if (v_39) {
         _fx_free_Nt6option1N10Ast__typ_t(&v_39);
      }
      if (v_38) {
         _fx_free_N10Ast__typ_t(&v_38);
      }

   _fx_endmatch_3: ;
      FX_CHECK_EXN(_fx_catch_15);
      FX_CALL(_fx_cons_LN10Ast__exp_t(e_4, eseq_2, true, &v_34), _fx_catch_15);
      _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_34, &env_7, &v_5);

   _fx_catch_15: ;
      if (v_34) {
         _fx_free_LN10Ast__exp_t(&v_34);
      }
      if (etyp_0) {
         _fx_free_N10Ast__typ_t(&etyp_0);
      }
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_33);
      if (e_4) {
         _fx_free_N10Ast__exp_t(&e_4);
      }
      if (e_3) {
         _fx_free_N10Ast__exp_t(&e_3);
      }

   _fx_endmatch_4: ;
      FX_CHECK_EXN(_fx_catch_16);

   _fx_catch_16: ;
      if (fx_status < 0) {
         fx_exn_get_and_reset(fx_status, &exn_0);
         fx_status = 0;
         _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_5);
         int tag_4 = exn_0.tag;
         if (tag_4 == _FX_EXN_E17Ast__CompileError) {
            _fx_LN10Ast__exp_t v_41 = 0;
            FX_CALL(_fx_M3AstFM16push_compile_errv1E(&exn_0, 0), _fx_catch_17);
            FX_CALL(_fx_cons_LN10Ast__exp_t(e_1, eseq_2, true, &v_41), _fx_catch_17);
            _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_41, &env_7, &v_5);

         _fx_catch_17: ;
            if (v_41) {
               _fx_free_LN10Ast__exp_t(&v_41);
            }
         }
         else if (tag_4 == _FX_EXN_E26Ast__PropagateCompileError) {
            _fx_LN10Ast__exp_t v_42 = 0;
            FX_CALL(_fx_cons_LN10Ast__exp_t(e_1, eseq_2, true, &v_42), _fx_catch_18);
            _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_42, &env_7, &v_5);

         _fx_catch_18: ;
            if (v_42) {
               _fx_free_LN10Ast__exp_t(&v_42);
            }
         }
         else {
            FX_THROW(&exn_0, false, _fx_catch_19);
         }
         FX_CHECK_EXN(_fx_catch_19);
      }
      FX_COPY_PTR(v_5.t0, &eseq1_0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_5.t1, &env1_0);
      _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(eseq1_0, &env1_0, &v_6);
      _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1);
      _fx_copy_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_6, &__fold_result___1);

   _fx_catch_19: ;
      _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_6);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0);
      if (eseq1_0) {
         _fx_free_LN10Ast__exp_t(&eseq1_0);
      }
      fx_free_exn(&exn_0);
      _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_5);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_7);
      if (eseq_2) {
         _fx_free_LN10Ast__exp_t(&eseq_2);
      }
      _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1, &v_0);
   FX_COPY_PTR(v_0.t0, &eseq_1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0.t1, &env_5);
   FX_CALL(_fx_M3AstFM18check_compile_errsv0(0), _fx_cleanup);
   _fx_LN10Ast__exp_t lst_2 = eseq_1;
   for (; lst_2; lst_2 = lst_2->tl) {
      _fx_LN10Ast__exp_t r_0 = 0;
      _fx_N10Ast__exp_t a_0 = lst_2->hd;
      FX_COPY_PTR(__fold_result___2, &r_0);
      FX_CALL(_fx_cons_LN10Ast__exp_t(a_0, r_0, false, &r_0), _fx_catch_20);
      _fx_free_LN10Ast__exp_t(&__fold_result___2);
      FX_COPY_PTR(r_0, &__fold_result___2);

   _fx_catch_20: ;
      if (r_0) {
         _fx_free_LN10Ast__exp_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___2, &v_1);
   _fx_make_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_1, &env_5, fx_result);

_fx_cleanup: ;
   FX_FREE_LIST_SIMPLE(&sc_1);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_4);
   _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1);
   _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
   if (eseq_1) {
      _fx_free_LN10Ast__exp_t(&eseq_1);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_5);
   if (__fold_result___2) {
      _fx_free_LN10Ast__exp_t(&__fold_result___2);
   }
   if (v_1) {
      _fx_free_LN10Ast__exp_t(&v_1);
   }
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM11is_importedB5R9Ast__id_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBR10Ast__loc_t(
   struct _fx_R9Ast__id_t* alias_0,
   int_ n_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   bool allow_duplicate_import_0,
   struct _fx_R10Ast__loc_t* loc_0,
   bool* fx_result,
   void* fx_fv)
{
   _fx_LN16Ast__env_entry_t v_0 = 0;
   int fx_status = 0;
   FX_CALL(
      _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(alias_0, env_0,
         &v_0, 0), _fx_cleanup);
   bool __fold_result___0 = false;
   _fx_LN16Ast__env_entry_t lst_0 = v_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N16Ast__env_entry_t a_0 = lst_0->hd;
      bool v_1;
      FX_CALL(
         _fx_M13Ast_typecheckFM10__lambda__B5N16Ast__env_entry_tR9Ast__id_tBR10Ast__loc_ti(a_0, alias_0,
            allow_duplicate_import_0, loc_0, n_0, &v_1, 0), _fx_catch_0);
      if (v_1) {
         __fold_result___0 = true; FX_BREAK(_fx_catch_0);
      }

   _fx_catch_0: ;
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   *fx_result = __fold_result___0;

_fx_cleanup: ;
   if (v_0) {
      _fx_free_LN16Ast__env_entry_t(&v_0);
   }
   return fx_status;
}

static int _fx_M13Ast_typecheckFM10__lambda__B5N16Ast__env_entry_tR9Ast__id_tBR10Ast__loc_ti(
   struct _fx_N16Ast__env_entry_t_data_t* entry_0,
   struct _fx_R9Ast__id_t* alias_0,
   bool allow_duplicate_import_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ n_0,
   bool* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   int tag_0 = FX_REC_VARIANT_TAG(entry_0);
   if (tag_0 == 1) {
      fx_exn_t exn_0 = {0};
      _fx_N14Ast__id_info_t v_0 = {0};
      fx_str_t v_1 = {0};
      fx_str_t v_2 = {0};
      fx_exn_t v_3 = {0};
      fx_str_t v_4 = {0};
      fx_str_t v_5 = {0};
      fx_str_t v_6 = {0};
      fx_exn_t v_7 = {0};
      fx_str_t v_8 = {0};
      fx_str_t v_9 = {0};
      fx_str_t v_10 = {0};
      fx_exn_t v_11 = {0};
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&entry_0->u.EnvId, loc_0, &v_0, 0), _fx_catch_0);
      int_ m_idx_0;
      if (v_0.tag == 8) {
         m_idx_0 = v_0.u.IdModule;
      }
      else {
         m_idx_0 = -1;
      }
      FX_CHECK_EXN(_fx_catch_0);
      _fx_R9Ast__id_t mname_0;
      FX_CALL(_fx_M3AstFM15get_module_nameRM4id_t1i(m_idx_0, &mname_0, 0), _fx_catch_0);
      if (m_idx_0 == n_0) {
         if (allow_duplicate_import_0) {
            *fx_result = true;
         }
         else {
            bool res_0;
            FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(alias_0, &mname_0, &res_0, 0), _fx_catch_0);
            if (res_0) {
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&mname_0, &v_1, 0), _fx_catch_0);
               fx_str_t slit_0 = FX_MAKE_STR("duplicate import of ");
               {
                  const fx_str_t strs_0[] = { slit_0, v_1 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_0, 2, &v_2), _fx_catch_0);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_2, &v_3, 0), _fx_catch_0);
               FX_THROW(&v_3, false, _fx_catch_0);
            }
            else {
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&mname_0, &v_4, 0), _fx_catch_0);
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(alias_0, &v_5, 0), _fx_catch_0);
               fx_str_t slit_1 = FX_MAKE_STR("duplicate import of ");
               fx_str_t slit_2 = FX_MAKE_STR(" as ");
               {
                  const fx_str_t strs_1[] = { slit_1, v_4, slit_2, v_5 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_1, 4, &v_6), _fx_catch_0);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_6, &v_7, 0), _fx_catch_0);
               FX_THROW(&v_7, false, _fx_catch_0);
            }
         }
      }
      else {
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&mname_0, &v_8, 0), _fx_catch_0);
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(alias_0, &v_9, 0), _fx_catch_0);
         fx_str_t slit_3 = FX_MAKE_STR("another module ");
         fx_str_t slit_4 = FX_MAKE_STR(" has been already imported as ");
         {
            const fx_str_t strs_2[] = { slit_3, v_8, slit_4, v_9 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_2, 4, &v_10), _fx_catch_0);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_10, &v_11, 0), _fx_catch_0);
         FX_THROW(&v_11, false, _fx_catch_0);
      }

   _fx_catch_0: ;
      _fx_free_N14Ast__id_info_t(&v_0);
      FX_FREE_STR(&v_1);
      FX_FREE_STR(&v_2);
      fx_free_exn(&v_3);
      FX_FREE_STR(&v_4);
      FX_FREE_STR(&v_5);
      FX_FREE_STR(&v_6);
      fx_free_exn(&v_7);
      FX_FREE_STR(&v_8);
      FX_FREE_STR(&v_9);
      FX_FREE_STR(&v_10);
      fx_free_exn(&v_11);
      if (fx_status < 0) {
         fx_exn_get_and_reset(fx_status, &exn_0);
         fx_status = 0;
         if (exn_0.tag == _FX_EXN_E4Fail) {
            *fx_result = false;
         }
         else {
            FX_RETHROW(&exn_0, _fx_catch_1);
         }
         FX_CHECK_EXN(_fx_catch_1);
      }

   _fx_catch_1: ;
      fx_free_exn(&exn_0);
   }
   else if (tag_0 == 2) {
      *fx_result = false;
   }
   else {
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_cleanup);
   }

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM14import_entriesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tiR9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   int_ parent_mod_0,
   struct _fx_R9Ast__id_t* key_0,
   struct _fx_LN16Ast__env_entry_t_data_t* entries_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
   _fx_LN16Ast__env_entry_t __fold_result___1 = 0;
   _fx_LN16Ast__env_entry_t v_0 = 0;
   int fx_status = 0;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &__fold_result___0);
   _fx_LN16Ast__env_entry_t lst_0 = entries_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_LN16Ast__env_entry_t r_0 = 0;
      _fx_N16Ast__env_entry_t a_0 = lst_0->hd;
      FX_COPY_PTR(__fold_result___1, &r_0);
      FX_CALL(_fx_cons_LN16Ast__env_entry_t(a_0, r_0, false, &r_0), _fx_catch_0);
      _fx_free_LN16Ast__env_entry_t(&__fold_result___1);
      FX_COPY_PTR(r_0, &__fold_result___1);

   _fx_catch_0: ;
      if (r_0) {
         _fx_free_LN16Ast__env_entry_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___1, &v_0);
   _fx_LN16Ast__env_entry_t lst_1 = v_0;
   for (; lst_1; lst_1 = lst_1->tl) {
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_1 = {0};
      _fx_N16Ast__env_entry_t i_0 = lst_1->hd;
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_1);
      int tag_0 = FX_REC_VARIANT_TAG(i_0);
      if (tag_0 == 1) {
         _fx_N14Ast__id_info_t info_0 = {0};
         _fx_LN12Ast__scope_t sc_0 = 0;
         _fx_R9Ast__id_t* i_1 = &i_0->u.EnvId;
         FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(i_1, loc_0, &info_0, 0), _fx_catch_3);
         FX_CALL(_fx_M3AstFM9get_scopeLN12Ast__scope_t1N14Ast__id_info_t(&info_0, &sc_0, 0), _fx_catch_3);
         if (sc_0 != 0) {
            _fx_N12Ast__scope_t* v_2 = &sc_0->hd;
            if (v_2->tag == 10) {
               bool t_0;
               if (parent_mod_0 == -1) {
                  t_0 = true;
               }
               else {
                  t_0 = parent_mod_0 == v_2->u.ScModule;
               }
               if (t_0) {
                  FX_CALL(
                     _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
                        key_0, i_1, &env_1, &v_1, 0), _fx_catch_1);

               _fx_catch_1: ;
                  goto _fx_endmatch_0;
               }
            }
         }
         if (info_0.tag == 8) {
            FX_CALL(
               _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
                  key_0, i_1, &env_1, &v_1, 0), _fx_catch_2);

         _fx_catch_2: ;
            goto _fx_endmatch_0;
         }
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &v_1);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_3);

      _fx_catch_3: ;
         FX_FREE_LIST_SIMPLE(&sc_0);
         _fx_free_N14Ast__id_info_t(&info_0);
      }
      else if (tag_0 == 2) {
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &v_1);
      }
      else {
         FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_4);
      }
      FX_CHECK_EXN(_fx_catch_4);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_1, &__fold_result___0);

   _fx_catch_4: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_1);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, fx_result);

_fx_cleanup: ;
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
   if (__fold_result___1) {
      _fx_free_LN16Ast__env_entry_t(&__fold_result___1);
   }
   if (v_0) {
      _fx_free_LN16Ast__env_entry_t(&v_0);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM16check_directivesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_LN10Ast__exp_t_data_t* eseq_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t __fold_result___0 = {0};
   _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t v_0 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   int fx_status = 0;
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(env_0, 0, &__fold_result___0);
   _fx_LN10Ast__exp_t lst_0 = eseq_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t v_1 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
      _fx_LT2iR10Ast__loc_t mlist_0 = 0;
      _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t v_2 = {0};
      _fx_N10Ast__exp_t e_0 = lst_0->hd;
      _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&__fold_result___0, &v_1);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_1.t0, &env_2);
      FX_COPY_PTR(v_1.t1, &mlist_0);
      int tag_0 = FX_REC_VARIANT_TAG(e_0);
      if (tag_0 == 40) {
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___1 = {0};
         _fx_LT2iR9Ast__id_t impdirs_0 = 0;
         _fx_T2LT2iR9Ast__id_tR10Ast__loc_t* vcase_0 = &e_0->u.DirImport;
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &__fold_result___1);
         FX_COPY_PTR(vcase_0->t0, &impdirs_0);
         _fx_LT2iR9Ast__id_t lst_1 = impdirs_0;
         for (; lst_1; lst_1 = lst_1->tl) {
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_3 = {0};
            fx_exn_t exn_0 = {0};
            _fx_T2iR9Ast__id_t* __pat___0 = &lst_1->hd;
            _fx_R9Ast__id_t alias_0 = __pat___0->t1;
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1, &env_3);
            FX_CALL(
               _fx_M13Ast_typecheckFM10import_modRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tiBR10Ast__loc_ti(
                  &env_3, &alias_0, __pat___0->t0, true, &vcase_0->t1, curr_m_idx_0, &v_3, 0), _fx_catch_0);

         _fx_catch_0: ;
            if (fx_status < 0) {
               fx_exn_get_and_reset(fx_status, &exn_0);
               fx_status = 0;
               _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_3);
               if (exn_0.tag == _FX_EXN_E17Ast__CompileError) {
                  FX_CALL(_fx_M3AstFM16push_compile_errv1E(&exn_0, 0), _fx_catch_1);
                  _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3, &v_3);

               _fx_catch_1: ;
               }
               else {
                  FX_RETHROW(&exn_0, _fx_catch_2);
               }
               FX_CHECK_EXN(_fx_catch_2);
            }
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_3, &__fold_result___1);

         _fx_catch_2: ;
            fx_free_exn(&exn_0);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_3);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
            FX_CHECK_EXN(_fx_catch_3);
         }
         _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&__fold_result___1, mlist_0, &v_2);

      _fx_catch_3: ;
         FX_FREE_LIST_SIMPLE(&impdirs_0);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1);
      }
      else if (tag_0 == 41) {
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_4 = {0};
         fx_exn_t exn_1 = {0};
         _fx_LT2iR10Ast__loc_t v_4 = 0;
         _fx_T3iLR9Ast__id_tR10Ast__loc_t* vcase_1 = &e_0->u.DirImportFrom;
         _fx_R10Ast__loc_t* eloc_0 = &vcase_1->t2;
         _fx_LR9Ast__id_t implist_0 = vcase_1->t1;
         int_ m_0 = vcase_1->t0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t menv_0 = {0};
         _fx_LR9Ast__id_t keys_0 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_5 = 0;
         _fx_FPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t __lambda___0 = {0};
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___2 = {0};
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_5 = {0};
         FX_CHKIDX(FX_CHKIDX1(_fx_g16Ast__all_modules, 0, m_0), _fx_catch_7);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
            &(*FX_PTR_1D(_fx_N16Ast__defmodule_t, _fx_g16Ast__all_modules, m_0))->u.defmodule_t.t6, &menv_0);
         if (implist_0 != 0) {
            FX_COPY_PTR(implist_0, &keys_0);
         }
         else {
            FX_COPY_PTR(menv_0.root, &v_5);
            _fx_FPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t __lambda___fp_0 =
               { _fx_M13Ast_typecheckFM10__lambda__LR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t, 0 };
            FX_COPY_FP(&__lambda___fp_0, &__lambda___0);
            FX_CALL(
               _fx_M13Ast_typecheckFM7update_LR9Ast__id_t3Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tFPLR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_tLR9Ast__id_t(
                  v_5, &__lambda___0, 0, &keys_0, 0), _fx_catch_7);
         }
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &__fold_result___2);
         _fx_LR9Ast__id_t lst_2 = keys_0;
         for (; lst_2; lst_2 = lst_2->tl) {
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_6 = {0};
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_6 = {0};
            fx_exn_t exn_2 = {0};
            _fx_R9Ast__id_t* k_0 = &lst_2->hd;
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___2, &env_6);
            _fx_LN16Ast__env_entry_t entries_0 = 0;
            fx_str_t v_7 = {0};
            fx_str_t v_8 = {0};
            fx_str_t v_9 = {0};
            fx_exn_t v_10 = {0};
            FX_CALL(
               _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(k_0,
                  &menv_0, &entries_0, 0), _fx_catch_4);
            if (entries_0 == 0) {
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(k_0, &v_7, 0), _fx_catch_4);
               _fx_R9Ast__id_t v_11;
               FX_CALL(_fx_M3AstFM15get_module_nameRM4id_t1i(m_0, &v_11, 0), _fx_catch_4);
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_11, &v_8, 0), _fx_catch_4);
               fx_str_t slit_0 = FX_MAKE_STR("no symbol ");
               fx_str_t slit_1 = FX_MAKE_STR(" found in ");
               {
                  const fx_str_t strs_0[] = { slit_0, v_7, slit_1, v_8 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_0, 4, &v_9), _fx_catch_4);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(eloc_0, &v_9, &v_10, 0), _fx_catch_4);
               FX_THROW(&v_10, false, _fx_catch_4);
            }
            FX_CALL(
               _fx_M13Ast_typecheckFM14import_entriesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tiR9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_t(
                  &env_6, m_0, k_0, entries_0, eloc_0, &v_6, 0), _fx_catch_4);

         _fx_catch_4: ;
            if (entries_0) {
               _fx_free_LN16Ast__env_entry_t(&entries_0);
            }
            FX_FREE_STR(&v_7);
            FX_FREE_STR(&v_8);
            FX_FREE_STR(&v_9);
            fx_free_exn(&v_10);
            if (fx_status < 0) {
               fx_exn_get_and_reset(fx_status, &exn_2);
               fx_status = 0;
               _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_6);
               if (exn_2.tag == _FX_EXN_E17Ast__CompileError) {
                  FX_CALL(_fx_M3AstFM16push_compile_errv1E(&exn_2, 0), _fx_catch_5);
                  _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_6, &v_6);

               _fx_catch_5: ;
               }
               else {
                  FX_RETHROW(&exn_2, _fx_catch_6);
               }
               FX_CHECK_EXN(_fx_catch_6);
            }
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___2);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_6, &__fold_result___2);

         _fx_catch_6: ;
            fx_free_exn(&exn_2);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_6);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_6);
            FX_CHECK_EXN(_fx_catch_7);
         }
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___2, &env_5);
         _fx_R9Ast__id_t alias_1;
         FX_CALL(_fx_M3AstFM15get_module_nameRM4id_t1i(m_0, &alias_1, 0), _fx_catch_7);
         FX_CALL(
            _fx_M13Ast_typecheckFM10import_modRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tiBR10Ast__loc_ti(
               &env_5, &alias_1, m_0, true, eloc_0, curr_m_idx_0, &env_4, 0), _fx_catch_7);

      _fx_catch_7: ;
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&menv_0);
         FX_FREE_LIST_SIMPLE(&keys_0);
         if (v_5) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_5);
         }
         FX_FREE_FP(&__lambda___0);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___2);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_5);
         if (fx_status < 0) {
            fx_exn_get_and_reset(fx_status, &exn_1);
            fx_status = 0;
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_4);
            if (exn_1.tag == _FX_EXN_E17Ast__CompileError) {
               FX_CALL(_fx_M3AstFM16push_compile_errv1E(&exn_1, 0), _fx_catch_8);
               _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &env_4);

            _fx_catch_8: ;
            }
            else {
               FX_RETHROW(&exn_1, _fx_catch_9);
            }
            FX_CHECK_EXN(_fx_catch_9);
         }
         _fx_T2iR10Ast__loc_t v_12 = { m_0, *eloc_0 };
         FX_CALL(_fx_cons_LT2iR10Ast__loc_t(&v_12, mlist_0, true, &v_4), _fx_catch_9);
         _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&env_4, v_4, &v_2);

      _fx_catch_9: ;
         FX_FREE_LIST_SIMPLE(&v_4);
         fx_free_exn(&exn_1);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_4);
      }
      else if (tag_0 == 42) {
         _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&env_2, mlist_0, &v_2);
      }
      else {
         _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&env_2, mlist_0, &v_2);
      }
      FX_CHECK_EXN(_fx_catch_10);
      _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&__fold_result___0);
      _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&v_2, &__fold_result___0);

   _fx_catch_10: ;
      _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&v_2);
      FX_FREE_LIST_SIMPLE(&mlist_0);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
      _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&v_1);
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&__fold_result___0, &v_0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0.t0, &env_1);
   FX_CALL(_fx_M3AstFM18check_compile_errsv0(0), _fx_cleanup);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, fx_result);

_fx_cleanup: ;
   _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&__fold_result___0);
   _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT2iR10Ast__loc_t(&v_0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM10import_modRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tiBR10Ast__loc_ti(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_R9Ast__id_t* alias_0,
   int_ m_idx_0,
   bool allow_duplicate_import_0,
   struct _fx_R10Ast__loc_t* loc_0,
   int_ curr_m_idx_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t menv_0 = {0};
   fx_str_t dm_filename_0 = {0};
   _fx_N14Ast__id_info_t v_0 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
   fx_str_t alias_path_0 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
   _fx_LR9Ast__id_t v_1 = 0;
   int fx_status = 0;
   bool v_2;
   FX_CALL(
      _fx_M13Ast_typecheckFM11is_importedB5R9Ast__id_tiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBR10Ast__loc_t(alias_0, m_idx_0,
         env_0, allow_duplicate_import_0, loc_0, &v_2, 0), _fx_cleanup);
   if (v_2) {
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, fx_result);
   }
   else {
      FX_CHKIDX(FX_CHKIDX1(_fx_g16Ast__all_modules, 0, m_idx_0), _fx_cleanup);
      _fx_T10R9Ast__id_tSiBLN10Ast__exp_tLiRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tBiNt9Dynvec__t1N14Ast__id_info_t* vcase_0 =
         &(*FX_PTR_1D(_fx_N16Ast__defmodule_t, _fx_g16Ast__all_modules, m_idx_0))->u.defmodule_t;
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&vcase_0->t6, &menv_0);
      fx_copy_str(&vcase_0->t1, &dm_filename_0);
      _fx_R9Ast__id_t dm_name_0 = vcase_0->t0;
      _fx_R9Ast__id_t m_id_0;
      FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, &dm_name_0, &m_id_0, 0), _fx_cleanup);
      _fx_M3AstFM8IdModuleN14Ast__id_info_t1i(m_idx_0, &v_0);
      FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&m_id_0, &v_0, 0), _fx_cleanup);
      FX_CALL(
         _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
            alias_0, &m_id_0, env_0, &env_1, 0), _fx_cleanup);
      FX_CALL(
         _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
            &dm_name_0, &m_id_0, &env_1, &env_2, 0), _fx_cleanup);
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(alias_0, &alias_path_0, 0), _fx_cleanup);
      FX_CALL(
         _fx_M13Ast_typecheckFM11add_parentsRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4SSRt6Map__t2R9Ast__id_tLN16Ast__env_entry_ti(
            &alias_path_0, &dm_filename_0, &env_2, curr_m_idx_0, &env_3, 0), _fx_cleanup);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3, &__fold_result___0);
      FX_CALL(_fx_M3AstFM19fname_always_importLRM4id_t0(&v_1, 0), _fx_cleanup);
      _fx_LR9Ast__id_t lst_0 = v_1;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_4 = {0};
         _fx_LN16Ast__env_entry_t entries_0 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_3 = {0};
         _fx_R9Ast__id_t* op_name_0 = &lst_0->hd;
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_4);
         FX_CALL(
            _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(op_name_0,
               &menv_0, &entries_0, 0), _fx_catch_0);
         FX_CALL(
            _fx_M13Ast_typecheckFM14import_entriesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tiR9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_t(
               &env_4, m_idx_0, op_name_0, entries_0, loc_0, &v_3, 0), _fx_catch_0);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_3, &__fold_result___0);

      _fx_catch_0: ;
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_3);
         if (entries_0) {
            _fx_free_LN16Ast__env_entry_t(&entries_0);
         }
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_4);
         FX_CHECK_EXN(_fx_cleanup);
      }
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, fx_result);
   }

_fx_cleanup: ;
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&menv_0);
   FX_FREE_STR(&dm_filename_0);
   _fx_free_N14Ast__id_info_t(&v_0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
   FX_FREE_STR(&alias_path_0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
   FX_FREE_LIST_SIMPLE(&v_1);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM11add_parentsRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4SSRt6Map__t2R9Ast__id_tLN16Ast__env_entry_ti(
   fx_str_t* alias_path_0,
   fx_str_t* fname_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   int_ curr_m_idx_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t result_0 = {0};
   fx_str_t alias_path_1 = {0};
   fx_str_t fname_1 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   int fx_status = 0;
   fx_copy_str(alias_path_0, &alias_path_1);
   fx_copy_str(fname_0, &fname_1);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &env_1);
   for (;;) {
      fx_str_t alias_path_2 = {0};
      fx_str_t fname_2 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
      fx_str_t parent_name_0 = {0};
      fx_str_t parent_fname_0 = {0};
      _fx_N14Ast__id_info_t v_0 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
      fx_copy_str(&alias_path_1, &alias_path_2);
      fx_copy_str(&fname_1, &fname_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &env_2);
      int_ idx_0 = _fx_M6StringFM5rfindi2SC(&alias_path_2, (char_)46, 0);
      if (idx_0 < 0) {
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&result_0);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, &result_0);
         FX_BREAK(_fx_catch_0);
      }
      else {
         FX_CALL(fx_substr(&alias_path_2, 0, idx_0, 1, 1, &parent_name_0), _fx_catch_0);
         _fx_R9Ast__id_t parent_id_0;
         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&parent_name_0, &parent_id_0, 0), _fx_catch_0);
         FX_CALL(_fx_M8FilenameFM7dirnameS1S(&fname_2, &parent_fname_0, 0), _fx_catch_0);
         int_ parent_idx_0;
         FX_CALL(_fx_M3AstFM11find_modulei2RM4id_tS(&parent_id_0, &parent_fname_0, &parent_idx_0, 0), _fx_catch_0);
         FX_CHKIDX(FX_CHKIDX1(_fx_g16Ast__all_modules, 0, parent_idx_0), _fx_catch_0);
         if (!(*FX_PTR_1D(_fx_N16Ast__defmodule_t, _fx_g16Ast__all_modules, parent_idx_0))->u.defmodule_t.t7) {
            FX_CHKIDX(FX_CHKIDX1(_fx_g16Ast__all_modules, 0, parent_idx_0), _fx_catch_0);
            (*FX_PTR_1D(_fx_N16Ast__defmodule_t, _fx_g16Ast__all_modules, parent_idx_0))->u.defmodule_t.t3 = false;
         }
         _fx_R9Ast__id_t local_parent_id_0;
         FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, &parent_id_0, &local_parent_id_0, 0), _fx_catch_0);
         _fx_M3AstFM8IdModuleN14Ast__id_info_t1i(parent_idx_0, &v_0);
         FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&local_parent_id_0, &v_0, 0), _fx_catch_0);
         FX_CALL(
            _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
               &parent_id_0, &local_parent_id_0, &env_2, &env_3, 0), _fx_catch_0);
         FX_FREE_STR(&alias_path_1);
         fx_copy_str(&parent_name_0, &alias_path_1);
         FX_FREE_STR(&fname_1);
         fx_copy_str(&parent_fname_0, &fname_1);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3, &env_1);
      }

   _fx_catch_0: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
      _fx_free_N14Ast__id_info_t(&v_0);
      FX_FREE_STR(&parent_fname_0);
      FX_FREE_STR(&parent_name_0);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
      FX_FREE_STR(&fname_2);
      FX_FREE_STR(&alias_path_2);
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&result_0, fx_result);

_fx_cleanup: ;
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&result_0);
   FX_FREE_STR(&alias_path_1);
   FX_FREE_STR(&fname_1);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM10__lambda__LR9Ast__id_t3R9Ast__id_tLN16Ast__env_entry_tLR9Ast__id_t(
   struct _fx_R9Ast__id_t* k_0,
   struct _fx_LN16Ast__env_entry_t_data_t* __0,
   struct _fx_LR9Ast__id_t_data_t* l_0,
   struct _fx_LR9Ast__id_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(_fx_cons_LR9Ast__id_t(k_0, l_0, true, fx_result), _fx_cleanup);

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9reg_typesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_LN10Ast__exp_t_data_t* eseq_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
   int fx_status = 0;
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &__fold_result___0);
   _fx_LN10Ast__exp_t lst_0 = eseq_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_0 = {0};
      _fx_N10Ast__exp_t e_0 = lst_0->hd;
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_1);
      int tag_0 = FX_REC_VARIANT_TAG(e_0);
      if (tag_0 == 37) {
         _fx_N10Ast__typ_t dt_typ_0 = 0;
         _fx_LR9Ast__id_t dt_templ_args_0 = 0;
         _fx_R13Ast__deftyp_t v_1 = {0};
         _fx_N14Ast__id_info_t v_2 = {0};
         _fx_FPv1N14Ast__id_info_t v_3 = {0};
         _fx_rR13Ast__deftyp_t dt_0 = e_0->u.DefTyp;
         _fx_R13Ast__deftyp_t* v_4 = &dt_0->data;
         _fx_R10Ast__loc_t dt_loc_0 = v_4->dt_loc;
         FX_COPY_PTR(v_4->dt_typ, &dt_typ_0);
         FX_COPY_PTR(v_4->dt_templ_args, &dt_templ_args_0);
         _fx_R9Ast__id_t dt_name_0 = v_4->dt_name;
         _fx_R9Ast__id_t dt_name1_0;
         FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, &dt_name_0, &dt_name1_0, 0), _fx_catch_0);
         _fx_make_R13Ast__deftyp_t(&dt_name1_0, dt_templ_args_0, dt_typ_0, false, sc_0, &dt_loc_0, &v_1);
         _fx_R13Ast__deftyp_t* v_5 = &dt_0->data;
         _fx_free_R13Ast__deftyp_t(v_5);
         _fx_copy_R13Ast__deftyp_t(&v_1, v_5);
         _fx_M3AstFM5IdTypN14Ast__id_info_t1rRM8deftyp_t(dt_0, &v_2);
         FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&dt_name1_0, &v_2, 0), _fx_catch_0);
         FX_CALL(
            _fx_M13Ast_typecheckFM23check_for_duplicate_typFPv1N14Ast__id_info_t3R9Ast__id_tLN12Ast__scope_tR10Ast__loc_t(
               &dt_name_0, sc_0, &dt_loc_0, &v_3, 0), _fx_catch_0);
         FX_CALL(
            _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
               &dt_name_0, &dt_name1_0, &env_1, &v_3, &v_0, 0), _fx_catch_0);

      _fx_catch_0: ;
         FX_FREE_FP(&v_3);
         _fx_free_N14Ast__id_info_t(&v_2);
         _fx_free_R13Ast__deftyp_t(&v_1);
         FX_FREE_LIST_SIMPLE(&dt_templ_args_0);
         if (dt_typ_0) {
            _fx_free_N10Ast__typ_t(&dt_typ_0);
         }
      }
      else if (tag_0 == 38) {
         _fx_LT2R9Ast__id_tLTa2R9Ast__id_t dvar_ifaces_0 = 0;
         _fx_LT2R9Ast__id_tN10Ast__typ_t dvar_cases_0 = 0;
         _fx_LR9Ast__id_t dvar_templ_args_0 = 0;
         _fx_LN10Ast__typ_t v_6 = 0;
         _fx_N10Ast__typ_t dvar_alias1_0 = 0;
         _fx_LR9Ast__id_t dummy_ctors_0 = 0;
         _fx_rLR9Ast__id_t v_7 = 0;
         _fx_R17Ast__defvariant_t v_8 = {0};
         _fx_N14Ast__id_info_t v_9 = {0};
         fx_exn_t v_10 = {0};
         _fx_FPv1N14Ast__id_info_t v_11 = {0};
         _fx_rR17Ast__defvariant_t dvar_0 = e_0->u.DefVariant;
         _fx_R17Ast__defvariant_t* v_12 = &dvar_0->data;
         _fx_R10Ast__loc_t dvar_loc_0 = v_12->dvar_loc;
         FX_COPY_PTR(v_12->dvar_ifaces, &dvar_ifaces_0);
         FX_COPY_PTR(v_12->dvar_cases, &dvar_cases_0);
         _fx_R16Ast__var_flags_t dvar_flags_0 = v_12->dvar_flags;
         FX_COPY_PTR(v_12->dvar_templ_args, &dvar_templ_args_0);
         _fx_R9Ast__id_t dvar_name_0 = v_12->dvar_name;
         _fx_R9Ast__id_t dvar_name1_0;
         FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, &dvar_name_0, &dvar_name1_0, 0), _fx_catch_3);
         _fx_LN10Ast__typ_t lstend_0 = 0;
         _fx_LR9Ast__id_t lst_1 = dvar_templ_args_0;
         for (; lst_1; lst_1 = lst_1->tl) {
            _fx_N10Ast__typ_t res_0 = 0;
            _fx_R9Ast__id_t* targ_0 = &lst_1->hd;
            FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, targ_0, &res_0), _fx_catch_1);
            _fx_LN10Ast__typ_t node_0 = 0;
            FX_CALL(_fx_cons_LN10Ast__typ_t(res_0, 0, false, &node_0), _fx_catch_1);
            FX_LIST_APPEND(v_6, lstend_0, node_0);

         _fx_catch_1: ;
            if (res_0) {
               _fx_free_N10Ast__typ_t(&res_0);
            }
            FX_CHECK_EXN(_fx_catch_3);
         }
         FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(v_6, &dvar_name1_0, &dvar_alias1_0), _fx_catch_3);
         _fx_LR9Ast__id_t lstend_1 = 0;
         _fx_LT2R9Ast__id_tN10Ast__typ_t lst_2 = dvar_cases_0;
         for (; lst_2; lst_2 = lst_2->tl) {
            _fx_T2R9Ast__id_tN10Ast__typ_t* __pat___0 = &lst_2->hd;
            _fx_LR9Ast__id_t node_1 = 0;
            FX_CALL(_fx_cons_LR9Ast__id_t(&__pat___0->t0, 0, false, &node_1), _fx_catch_2);
            FX_LIST_APPEND(dummy_ctors_0, lstend_1, node_1);

         _fx_catch_2: ;
            FX_CHECK_EXN(_fx_catch_3);
         }
         FX_CALL(_fx_make_rLR9Ast__id_t(0, &v_7), _fx_catch_3);
         _fx_make_R17Ast__defvariant_t(&dvar_name1_0, dvar_templ_args_0, dvar_alias1_0, &dvar_flags_0, dvar_cases_0,
            dummy_ctors_0, v_7, dvar_ifaces_0, sc_0, &dvar_loc_0, &v_8);
         _fx_R17Ast__defvariant_t* v_13 = &dvar_0->data;
         _fx_free_R17Ast__defvariant_t(v_13);
         _fx_copy_R17Ast__defvariant_t(&v_8, v_13);
         _fx_M3AstFM9IdVariantN14Ast__id_info_t1rRM12defvariant_t(dvar_0, &v_9);
         FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&dvar_name1_0, &v_9, 0), _fx_catch_3);
         bool t_0;
         if (dvar_ifaces_0 != 0) {
            t_0 = dvar_templ_args_0 != 0;
         }
         else {
            t_0 = false;
         }
         if (t_0) {
            fx_str_t slit_0 = FX_MAKE_STR("generic variants may not implement any interfaces");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&dvar_loc_0, &slit_0, &v_10, 0), _fx_catch_3);
            FX_THROW(&v_10, false, _fx_catch_3);
         }
         FX_CALL(
            _fx_M13Ast_typecheckFM23check_for_duplicate_typFPv1N14Ast__id_info_t3R9Ast__id_tLN12Ast__scope_tR10Ast__loc_t(
               &dvar_name_0, sc_0, &dvar_loc_0, &v_11, 0), _fx_catch_3);
         FX_CALL(
            _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
               &dvar_name_0, &dvar_name1_0, &env_1, &v_11, &v_0, 0), _fx_catch_3);

      _fx_catch_3: ;
         FX_FREE_FP(&v_11);
         fx_free_exn(&v_10);
         _fx_free_N14Ast__id_info_t(&v_9);
         _fx_free_R17Ast__defvariant_t(&v_8);
         if (v_7) {
            _fx_free_rLR9Ast__id_t(&v_7);
         }
         FX_FREE_LIST_SIMPLE(&dummy_ctors_0);
         if (dvar_alias1_0) {
            _fx_free_N10Ast__typ_t(&dvar_alias1_0);
         }
         if (v_6) {
            _fx_free_LN10Ast__typ_t(&v_6);
         }
         FX_FREE_LIST_SIMPLE(&dvar_templ_args_0);
         if (dvar_cases_0) {
            _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&dvar_cases_0);
         }
         if (dvar_ifaces_0) {
            _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(&dvar_ifaces_0);
         }
      }
      else if (tag_0 == 39) {
         _fx_R19Ast__definterface_t v_14 = {0};
         _fx_N14Ast__id_info_t v_15 = {0};
         _fx_FPv1N14Ast__id_info_t v_16 = {0};
         _fx_rR19Ast__definterface_t di_0 = e_0->u.DefInterface;
         _fx_R19Ast__definterface_t* v_17 = &di_0->data;
         _fx_R10Ast__loc_t di_loc_0 = v_17->di_loc;
         _fx_R9Ast__id_t di_name_0 = v_17->di_name;
         if (sc_0 != 0) {
            if (sc_0->hd.tag == 10) {
               goto _fx_endmatch_0;
            }
         }
         fx_exn_t v_18 = {0};
         fx_str_t slit_1 = FX_MAKE_STR("interfaces should be declared at a module level");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&di_loc_0, &slit_1, &v_18, 0), _fx_catch_4);
         FX_THROW(&v_18, false, _fx_catch_4);

      _fx_catch_4: ;
         fx_free_exn(&v_18);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_5);
         _fx_R9Ast__id_t di_name1_0;
         FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, &di_name_0, &di_name1_0, 0), _fx_catch_5);
         _fx_R19Ast__definterface_t* v_19 = &di_0->data;
         _fx_make_R19Ast__definterface_t(&di_name1_0, &v_19->di_base, v_19->di_new_methods, v_19->di_all_methods, sc_0,
            &v_19->di_loc, &v_14);
         _fx_R19Ast__definterface_t* v_20 = &di_0->data;
         _fx_free_R19Ast__definterface_t(v_20);
         _fx_copy_R19Ast__definterface_t(&v_14, v_20);
         _fx_M3AstFM11IdInterfaceN14Ast__id_info_t1rRM14definterface_t(di_0, &v_15);
         FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&di_name1_0, &v_15, 0), _fx_catch_5);
         FX_CALL(
            _fx_M13Ast_typecheckFM23check_for_duplicate_typFPv1N14Ast__id_info_t3R9Ast__id_tLN12Ast__scope_tR10Ast__loc_t(
               &di_name_0, sc_0, &di_loc_0, &v_16, 0), _fx_catch_5);
         FX_CALL(
            _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
               &di_name_0, &di_name1_0, &env_1, &v_16, &v_0, 0), _fx_catch_5);

      _fx_catch_5: ;
         FX_FREE_FP(&v_16);
         _fx_free_N14Ast__id_info_t(&v_15);
         _fx_free_R19Ast__definterface_t(&v_14);
      }
      else {
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &v_0);
      }
      FX_CHECK_EXN(_fx_catch_6);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0, &__fold_result___0);

   _fx_catch_6: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, fx_result);

_fx_cleanup: ;
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM24register_typ_constructorT2R9Ast__id_tN10Ast__typ_t8R9Ast__id_tN17Ast__fun_constr_tLR9Ast__id_tLN10Ast__typ_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_N17Ast__fun_constr_t* ctor_0,
   struct _fx_LR9Ast__id_t_data_t* templ_args_0,
   struct _fx_LN10Ast__typ_t_data_t* argtyps_0,
   struct _fx_N10Ast__typ_t_data_t* rt_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* decl_loc_0,
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t ctor_typ_0 = 0;
   _fx_LN10Ast__pat_t args_0 = 0;
   _fx_N10Ast__typ_t v_0 = 0;
   _fx_N10Ast__exp_t v_1 = 0;
   _fx_rLR9Ast__id_t v_2 = 0;
   _fx_R13Ast__deffun_t v_3 = {0};
   _fx_rR13Ast__deffun_t df_0 = 0;
   _fx_N14Ast__id_info_t v_4 = {0};
   int fx_status = 0;
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   if (argtyps_0 == 0) {
      FX_COPY_PTR(rt_0, &ctor_typ_0);
   }
   else {
      FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(argtyps_0, rt_0, &ctor_typ_0), _fx_catch_0);

   _fx_catch_0: ;
   }
   FX_CHECK_EXN(_fx_cleanup);
   _fx_LN10Ast__pat_t lstend_0 = 0;
   int_ i_0 = 0;
   _fx_LN10Ast__typ_t lst_0 = argtyps_0;
   for (; lst_0; lst_0 = lst_0->tl, i_0 += 1) {
      fx_str_t v_5 = {0};
      fx_str_t v_6 = {0};
      _fx_N10Ast__pat_t res_0 = 0;
      _fx_N10Ast__typ_t __pat___0 = lst_0->hd;
      FX_CALL(_fx_F6stringS1i(i_0, &v_5, 0), _fx_catch_1);
      fx_str_t slit_0 = FX_MAKE_STR("arg");
      {
         const fx_str_t strs_0[] = { slit_0, v_5 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_0, 2, &v_6), _fx_catch_1);
      }
      _fx_R9Ast__id_t v_7;
      FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_6, &v_7, 0), _fx_catch_1);
      FX_CALL(_fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&v_7, decl_loc_0, &res_0), _fx_catch_1);
      _fx_LN10Ast__pat_t node_0 = 0;
      FX_CALL(_fx_cons_LN10Ast__pat_t(res_0, 0, false, &node_0), _fx_catch_1);
      FX_LIST_APPEND(args_0, lstend_0, node_0);

   _fx_catch_1: ;
      if (res_0) {
         _fx_free_N10Ast__pat_t(&res_0);
      }
      FX_FREE_STR(&v_6);
      FX_FREE_STR(&v_5);
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(rt_0, &v_0, 0), _fx_cleanup);
   bool is_instance_0;
   if (FX_REC_VARIANT_TAG(v_0) == 24) {
      if (v_0->u.TypApp.t0 != 0) {
         is_instance_0 = true; goto _fx_endmatch_0;
      }
   }
   is_instance_0 = false;

_fx_endmatch_0: ;
   FX_CHECK_EXN(_fx_cleanup);
   _fx_R9Ast__id_t ctor_name_0;
   FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, n_0, &ctor_name_0, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM6ExpNopN10Ast__exp_t1RM5loc_t(decl_loc_0, &v_1), _fx_cleanup);
   _fx_R16Ast__fun_flags_t v_8;
   FX_CALL(_fx_M3AstFM17default_fun_flagsRM11fun_flags_t0(&v_8, 0), _fx_cleanup);
   _fx_R16Ast__fun_flags_t v_9 =
      { v_8.fun_flag_pure, v_8.fun_flag_ccode, v_8.fun_flag_have_keywords, v_8.fun_flag_inline, v_8.fun_flag_nothrow,
         v_8.fun_flag_really_nothrow, v_8.fun_flag_private, *ctor_0, v_8.fun_flag_method_of, v_8.fun_flag_uses_fv,
         v_8.fun_flag_recursive, is_instance_0 };
   FX_CALL(_fx_make_rLR9Ast__id_t(0, &v_2), _fx_cleanup);
   _fx_make_R13Ast__deffun_t(&ctor_name_0, templ_args_0, args_0, ctor_typ_0, v_1, &v_9, sc_0, decl_loc_0, v_2, env_0, &v_3);
   FX_CALL(_fx_make_rR13Ast__deffun_t(&v_3, &df_0), _fx_cleanup);
   _fx_M3AstFM5IdFunN14Ast__id_info_t1rRM8deffun_t(df_0, &v_4);
   FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&ctor_name_0, &v_4, 0), _fx_cleanup);
   _fx_make_T2R9Ast__id_tN10Ast__typ_t(&ctor_name_0, ctor_typ_0, fx_result);

_fx_cleanup: ;
   if (ctor_typ_0) {
      _fx_free_N10Ast__typ_t(&ctor_typ_0);
   }
   if (args_0) {
      _fx_free_LN10Ast__pat_t(&args_0);
   }
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   if (v_1) {
      _fx_free_N10Ast__exp_t(&v_1);
   }
   if (v_2) {
      _fx_free_rLR9Ast__id_t(&v_2);
   }
   _fx_free_R13Ast__deffun_t(&v_3);
   if (df_0) {
      _fx_free_rR13Ast__deffun_t(&df_0);
   }
   _fx_free_N14Ast__id_info_t(&v_4);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM11check_typesRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_LN10Ast__exp_t_data_t* eseq_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &__fold_result___0);
   _fx_LN10Ast__exp_t lst_0 = eseq_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_0 = {0};
      _fx_N10Ast__exp_t e_0 = lst_0->hd;
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_1);
      int tag_0 = FX_REC_VARIANT_TAG(e_0);
      if (tag_0 == 37) {
         _fx_LN12Ast__scope_t dt_scope_0 = 0;
         _fx_N10Ast__typ_t dt_typ_0 = 0;
         _fx_LR9Ast__id_t dt_templ_args_0 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___1 = {0};
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_0 = {0};
         _fx_N10Ast__typ_t v_1 = 0;
         _fx_N10Ast__typ_t dt_typ_1 = 0;
         _fx_R13Ast__deftyp_t v_2 = {0};
         _fx_rR13Ast__deftyp_t dt_0 = e_0->u.DefTyp;
         _fx_R13Ast__deftyp_t* v_3 = &dt_0->data;
         _fx_R10Ast__loc_t dt_loc_0 = v_3->dt_loc;
         FX_COPY_PTR(v_3->dt_scope, &dt_scope_0);
         FX_COPY_PTR(v_3->dt_typ, &dt_typ_0);
         FX_COPY_PTR(v_3->dt_templ_args, &dt_templ_args_0);
         _fx_R9Ast__id_t dt_name_0 = v_3->dt_name;
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &__fold_result___1);
         _fx_LR9Ast__id_t lst_1 = dt_templ_args_0;
         for (; lst_1; lst_1 = lst_1->tl) {
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_1 = {0};
            _fx_N10Ast__typ_t v_4 = 0;
            _fx_LN16Ast__env_entry_t entries_0 = 0;
            _fx_N16Ast__env_entry_t v_5 = 0;
            _fx_LN16Ast__env_entry_t v_6 = 0;
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_7 = 0;
            _fx_FPi2R9Ast__id_tR9Ast__id_t v_8 = {0};
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_9 = 0;
            _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_10 = {0};
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
            _fx_FPi2R9Ast__id_tR9Ast__id_t v_11 = {0};
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_12 = {0};
            _fx_R9Ast__id_t* t_arg_0 = &lst_1->hd;
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1, &env1_1);
            FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, t_arg_0, &v_4), _fx_catch_1);
            FX_CALL(
               _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(t_arg_0,
                  &env1_1, &entries_0, 0), _fx_catch_1);
            FX_CALL(_fx_M3AstFM6EnvTypN16Ast__env_entry_t1N10Ast__typ_t(v_4, &v_5), _fx_catch_1);
            FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_5, entries_0, true, &v_6), _fx_catch_1);
            FX_COPY_PTR(env1_1.root, &v_7);
            FX_COPY_FP(&env1_1.cmp, &v_8);
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
                  v_7, t_arg_0, v_6, &v_8, &v_9, 0), _fx_catch_1);
            if ((v_9 != 0) + 1 == 2) {
               _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
                  vcase_0 = &v_9->u.Node;
               if (vcase_0->t0.tag == 1) {
                  _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_13 = 0;
                  FX_CALL(
                     _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                        &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_13), _fx_catch_0);
                  _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_13, false, &v_10);

               _fx_catch_0: ;
                  if (v_13) {
                     _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_13);
                  }
                  goto _fx_endmatch_0;
               }
            }
            _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_9, true, &v_10);

         _fx_endmatch_0: ;
            FX_CHECK_EXN(_fx_catch_1);
            FX_COPY_PTR(v_10.t0, &new_root_0);
            FX_COPY_FP(&env1_1.cmp, &v_11);
            _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_11, &v_12);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_12, &__fold_result___1);

         _fx_catch_1: ;
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_12);
            FX_FREE_FP(&v_11);
            if (new_root_0) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
            }
            _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_10);
            if (v_9) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_9);
            }
            FX_FREE_FP(&v_8);
            if (v_7) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_7);
            }
            if (v_6) {
               _fx_free_LN16Ast__env_entry_t(&v_6);
            }
            if (v_5) {
               _fx_free_N16Ast__env_entry_t(&v_5);
            }
            if (entries_0) {
               _fx_free_LN16Ast__env_entry_t(&entries_0);
            }
            if (v_4) {
               _fx_free_N10Ast__typ_t(&v_4);
            }
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_1);
            FX_CHECK_EXN(_fx_catch_2);
         }
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1, &env1_0);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               dt_typ_0, &env1_0, dt_scope_0, &dt_loc_0, &v_1, 0), _fx_catch_2);
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(v_1, &dt_typ_1, 0), _fx_catch_2);
         _fx_make_R13Ast__deftyp_t(&dt_name_0, dt_templ_args_0, dt_typ_1, true, dt_scope_0, &dt_loc_0, &v_2);
         _fx_R13Ast__deftyp_t* v_14 = &dt_0->data;
         _fx_free_R13Ast__deftyp_t(v_14);
         _fx_copy_R13Ast__deftyp_t(&v_2, v_14);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &v_0);

      _fx_catch_2: ;
         _fx_free_R13Ast__deftyp_t(&v_2);
         if (dt_typ_1) {
            _fx_free_N10Ast__typ_t(&dt_typ_1);
         }
         if (v_1) {
            _fx_free_N10Ast__typ_t(&v_1);
         }
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___1);
         FX_FREE_LIST_SIMPLE(&dt_templ_args_0);
         if (dt_typ_0) {
            _fx_free_N10Ast__typ_t(&dt_typ_0);
         }
         FX_FREE_LIST_SIMPLE(&dt_scope_0);
      }
      else if (tag_0 == 38) {
         _fx_T2R9Ast__id_tN10Ast__typ_t res_0 = {0};
         _fx_LR9Ast__id_t dvar_ctors_0 = 0;
         _fx_LT2R9Ast__id_tN10Ast__typ_t dvar_cases_0 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___2 = {0};
         _fx_rR17Ast__defvariant_t dvar_0 = e_0->u.DefVariant;
         _fx_R10Ast__loc_t v_15 = dvar_0->data.dvar_loc;
         FX_CALL(
            _fx_M13Ast_typecheckFM19instantiate_variantT2R9Ast__id_tN10Ast__typ_t5LN10Ast__typ_trR17Ast__defvariant_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               0, dvar_0, &env_1, sc_0, &v_15, &res_0, 0), _fx_catch_5);
         _fx_R17Ast__defvariant_t* v_16 = &dvar_0->data;
         _fx_R10Ast__loc_t dvar_loc_0 = v_16->dvar_loc;
         FX_COPY_PTR(v_16->dvar_ctors, &dvar_ctors_0);
         FX_COPY_PTR(v_16->dvar_cases, &dvar_cases_0);
         _fx_R9Ast__id_t dvar_name_0 = v_16->dvar_name;
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &__fold_result___2);
         _fx_LT2R9Ast__id_tN10Ast__typ_t lst_2 = dvar_cases_0;
         _fx_LR9Ast__id_t lst_3 = dvar_ctors_0;
         for (; lst_2 && lst_3; lst_3 = lst_3->tl, lst_2 = lst_2->tl) {
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
            _fx_N14Ast__id_info_t v_17 = {0};
            _fx_R13Ast__deffun_t v_18 = {0};
            _fx_N10Ast__typ_t df_typ_0 = 0;
            _fx_LR9Ast__id_t df_templ_args_0 = 0;
            _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_19 = {0};
            _fx_N10Ast__typ_t t_0 = 0;
            _fx_FPv1N14Ast__id_info_t v_20 = {0};
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_21 = {0};
            _fx_R9Ast__id_t* ctor_name_0 = &lst_3->hd;
            _fx_T2R9Ast__id_tN10Ast__typ_t* __pat___0 = &lst_2->hd;
            _fx_R9Ast__id_t n_0 = __pat___0->t0;
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___2, &env_2);
            FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(ctor_name_0, &dvar_loc_0, &v_17, 0), _fx_catch_4);
            if (v_17.tag == 3) {
               _fx_copy_R13Ast__deffun_t(&v_17.u.IdFun->data, &v_18);
            }
            else {
               fx_str_t v_22 = {0};
               fx_str_t v_23 = {0};
               fx_str_t v_24 = {0};
               fx_exn_t v_25 = {0};
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&dvar_name_0, &v_22, 0), _fx_catch_3);
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(ctor_name_0, &v_23, 0), _fx_catch_3);
               fx_str_t slit_0 = FX_MAKE_STR("internal error: constructor ");
               fx_str_t slit_1 = FX_MAKE_STR(".");
               fx_str_t slit_2 = FX_MAKE_STR(" is not a function");
               {
                  const fx_str_t strs_0[] = { slit_0, v_22, slit_1, v_23, slit_2 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_0, 5, &v_24), _fx_catch_3);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&dvar_loc_0, &v_24, &v_25, 0), _fx_catch_3);
               FX_THROW(&v_25, false, _fx_catch_3);

            _fx_catch_3: ;
               fx_free_exn(&v_25);
               FX_FREE_STR(&v_24);
               FX_FREE_STR(&v_23);
               FX_FREE_STR(&v_22);
            }
            FX_CHECK_EXN(_fx_catch_4);
            FX_COPY_PTR(v_18.df_typ, &df_typ_0);
            FX_COPY_PTR(v_18.df_templ_args, &df_templ_args_0);
            FX_CALL(
               _fx_M13Ast_typecheckFM20preprocess_templ_typT2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5LR9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  df_templ_args_0, df_typ_0, &env_2, sc_0, &dvar_loc_0, &v_19, 0), _fx_catch_4);
            FX_COPY_PTR(v_19.t0, &t_0);
            FX_CALL(
               _fx_M13Ast_typecheckFM23check_for_duplicate_funFPv1N14Ast__id_info_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  t_0, &env_2, sc_0, &dvar_loc_0, &v_20, 0), _fx_catch_4);
            FX_CALL(
               _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
                  &n_0, ctor_name_0, &env_2, &v_20, &v_21, 0), _fx_catch_4);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___2);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_21, &__fold_result___2);

         _fx_catch_4: ;
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_21);
            FX_FREE_FP(&v_20);
            if (t_0) {
               _fx_free_N10Ast__typ_t(&t_0);
            }
            _fx_free_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_19);
            FX_FREE_LIST_SIMPLE(&df_templ_args_0);
            if (df_typ_0) {
               _fx_free_N10Ast__typ_t(&df_typ_0);
            }
            _fx_free_R13Ast__deffun_t(&v_18);
            _fx_free_N14Ast__id_info_t(&v_17);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
            FX_CHECK_EXN(_fx_catch_5);
         }
         int s_0 = !lst_2 + !lst_3;
         FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_5);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___2, &v_0);

      _fx_catch_5: ;
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___2);
         if (dvar_cases_0) {
            _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&dvar_cases_0);
         }
         FX_FREE_LIST_SIMPLE(&dvar_ctors_0);
         _fx_free_T2R9Ast__id_tN10Ast__typ_t(&res_0);
      }
      else if (tag_0 == 39) {
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t di_new_methods_0 = 0;
         _fx_R19Ast__definterface_t ibase_0 = {0};
         _fx_N10Ast__typ_t v_26 = 0;
         _fx_N10Ast__typ_t v_27 = 0;
         _fx_LN12Ast__scope_t sc_1 = 0;
         _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t __fold_result___3 = {0};
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_28 = 0;
         _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_29 = {0};
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_2 = {0};
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t base_members_0 = 0;
         _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t __fold_result___4 = {0};
         _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_30 = {0};
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t all_members_0 = 0;
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t __fold_result___5 = 0;
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_31 = 0;
         _fx_R19Ast__definterface_t v_32 = {0};
         _fx_rR19Ast__definterface_t di_0 = e_0->u.DefInterface;
         _fx_R19Ast__definterface_t* v_33 = &di_0->data;
         _fx_R10Ast__loc_t di_loc_0 = v_33->di_loc;
         FX_COPY_PTR(v_33->di_new_methods, &di_new_methods_0);
         _fx_R9Ast__id_t di_base_0 = v_33->di_base;
         _fx_R9Ast__id_t di_name_0 = v_33->di_name;
         bool res_1;
         FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&di_base_0, &_fx_g9Ast__noid, &res_1, 0), _fx_catch_11);
         if (res_1) {
            _fx_make_R19Ast__definterface_t(&_fx_g9Ast__noid, &_fx_g9Ast__noid, 0, 0, sc_0, &di_loc_0, &ibase_0);
         }
         else {
            FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, &di_base_0, &v_26), _fx_catch_11);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  v_26, &env_1, sc_0, &di_loc_0, &v_27, 0), _fx_catch_11);
            if (FX_REC_VARIANT_TAG(v_27) == 24) {
               _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_1 = &v_27->u.TypApp;
               if (vcase_1->t0 == 0) {
                  _fx_rR19Ast__definterface_t v_34 = 0;
                  FX_CALL(_fx_M3AstFM9get_ifacerRM14definterface_t2RM4id_tRM5loc_t(&vcase_1->t1, &di_loc_0, &v_34, 0),
                     _fx_catch_6);
                  _fx_copy_R19Ast__definterface_t(&v_34->data, &ibase_0);

               _fx_catch_6: ;
                  if (v_34) {
                     _fx_free_rR19Ast__definterface_t(&v_34);
                  }
                  goto _fx_endmatch_1;
               }
            }
            fx_str_t v_35 = {0};
            fx_str_t v_36 = {0};
            fx_str_t v_37 = {0};
            fx_exn_t v_38 = {0};
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&di_name_0, &v_35, 0), _fx_catch_7);
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&di_base_0, &v_36, 0), _fx_catch_7);
            fx_str_t slit_3 = FX_MAKE_STR("base type of \'");
            fx_str_t slit_4 = FX_MAKE_STR("\', \'");
            fx_str_t slit_5 = FX_MAKE_STR("\' is not an interface");
            {
               const fx_str_t strs_1[] = { slit_3, v_35, slit_4, v_36, slit_5 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_1, 5, &v_37), _fx_catch_7);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&di_loc_0, &v_37, &v_38, 0), _fx_catch_7);
            FX_THROW(&v_38, false, _fx_catch_7);

         _fx_catch_7: ;
            fx_free_exn(&v_38);
            FX_FREE_STR(&v_37);
            FX_FREE_STR(&v_36);
            FX_FREE_STR(&v_35);

         _fx_endmatch_1: ;
            FX_CHECK_EXN(_fx_catch_11);
         }
         _fx_N12Ast__scope_t v_39;
         _fx_M3AstFM11ScInterfaceN12Ast__scope_t1RM4id_t(&di_name_0, &v_39);
         FX_CALL(_fx_cons_LN12Ast__scope_t(&v_39, sc_0, true, &sc_1), _fx_catch_11);
         int_ curr_m_idx_0;
         FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_1, &curr_m_idx_0, 0), _fx_catch_11);
         _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&env_1, 0,
            &__fold_result___3);
         FX_COPY_PTR(ibase_0.di_all_methods, &v_28);
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t lst_4 = v_28;
         for (; lst_4; lst_4 = lst_4->tl) {
            _fx_N10Ast__typ_t t_1 = 0;
            _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_40 = {0};
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_3 = {0};
            _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t base_members_1 = 0;
            _fx_FPv1N14Ast__id_info_t v_41 = {0};
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_4 = {0};
            _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_42 = {0};
            _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_43 = {0};
            _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* __pat___1 = &lst_4->hd;
            _fx_R9Ast__id_t f_0 = __pat___1->t0;
            FX_COPY_PTR(__pat___1->t1, &t_1);
            _fx_R16Ast__fun_flags_t flags_0 = __pat___1->t2;
            _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
               &__fold_result___3, &v_40);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_40.t0, &env1_3);
            FX_COPY_PTR(v_40.t1, &base_members_1);
            _fx_R9Ast__id_t v_44;
            FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&f_0, &v_44, 0), _fx_catch_8);
            FX_CALL(
               _fx_M13Ast_typecheckFM26check_for_duplicate_methodFPv1N14Ast__id_info_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  t_1, &env1_3, sc_1, &di_loc_0, &v_41, 0), _fx_catch_8);
            FX_CALL(
               _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
                  &v_44, &f_0, &env1_3, &v_41, &env1_4, 0), _fx_catch_8);
            _fx_make_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&f_0, t_1, &flags_0, &v_42);
            FX_CALL(_fx_cons_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_42, base_members_1, false, &base_members_1),
               _fx_catch_8);
            _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&env1_4,
               base_members_1, &v_43);
            _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
               &__fold_result___3);
            _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_43,
               &__fold_result___3);

         _fx_catch_8: ;
            _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_43);
            _fx_free_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_42);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_4);
            FX_FREE_FP(&v_41);
            if (base_members_1) {
               _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&base_members_1);
            }
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_3);
            _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_40);
            if (t_1) {
               _fx_free_N10Ast__typ_t(&t_1);
            }
            FX_CHECK_EXN(_fx_catch_11);
         }
         _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___3,
            &v_29);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_29.t0, &env1_2);
         FX_COPY_PTR(v_29.t1, &base_members_0);
         int_ base_idx_0 = _fx_M13Ast_typecheckFM6lengthi1LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(base_members_0, 0);
         _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&env1_2,
            base_members_0, &__fold_result___4);
         int_ idx_0 = 0;
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t lst_5 = di_new_methods_0;
         for (; lst_5; lst_5 = lst_5->tl, idx_0 += 1) {
            _fx_N10Ast__typ_t t_2 = 0;
            _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_45 = {0};
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_5 = {0};
            _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t all_members_1 = 0;
            _fx_N10Ast__typ_t t_3 = 0;
            fx_str_t v_46 = {0};
            fx_str_t v_47 = {0};
            fx_exn_t v_48 = {0};
            _fx_R16Ast__val_flags_t v_49 = {0};
            _fx_R16Ast__val_flags_t dv_flags_0 = {0};
            _fx_R13Ast__defval_t v_50 = {0};
            _fx_N14Ast__id_info_t v_51 = {0};
            _fx_FPv1N14Ast__id_info_t v_52 = {0};
            _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_6 = {0};
            _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_53 = {0};
            _fx_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_54 = {0};
            _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* __pat___2 = &lst_5->hd;
            _fx_R9Ast__id_t f_1 = __pat___2->t0;
            FX_COPY_PTR(__pat___2->t1, &t_2);
            _fx_R16Ast__fun_flags_t flags_1 = __pat___2->t2;
            _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
               &__fold_result___4, &v_45);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_45.t0, &env1_5);
            FX_COPY_PTR(v_45.t1, &all_members_1);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  t_2, &env_1, sc_1, &di_loc_0, &t_3, 0), _fx_catch_9);
            bool v_55;
            FX_CALL(_fx_M3AstFM12is_fixed_typB1N10Ast__typ_t(t_3, &v_55, 0), _fx_catch_9);
            if (!v_55) {
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&f_1, &v_46, 0), _fx_catch_9);
               fx_str_t slit_6 = FX_MAKE_STR("some of the argument types or the return type of method \'");
               fx_str_t slit_7 = FX_MAKE_STR("\' are not specified");
               {
                  const fx_str_t strs_2[] = { slit_6, v_46, slit_7 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_2, 3, &v_47), _fx_catch_9);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&di_loc_0, &v_47, &v_48, 0), _fx_catch_9);
               FX_THROW(&v_48, false, _fx_catch_9);
            }
            _fx_R9Ast__id_t f1_0;
            FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, &f_1, &f1_0, 0), _fx_catch_9);
            FX_CALL(_fx_M3AstFM17default_val_flagsRM11val_flags_t0(&v_49, 0), _fx_catch_9);
            _fx_T2R9Ast__id_ti v_56 = { di_name_0, idx_0 + base_idx_0 };
            _fx_make_R16Ast__val_flags_t(v_49.val_flag_arg, v_49.val_flag_mutable, v_49.val_flag_temp, v_49.val_flag_tempref,
               v_49.val_flag_private, v_49.val_flag_subarray, v_49.val_flag_instance, &v_56, v_49.val_flag_ctor,
               v_49.val_flag_global, &dv_flags_0);
            _fx_make_R13Ast__defval_t(&f1_0, t_3, &dv_flags_0, sc_1, &di_loc_0, &v_50);
            _fx_M3AstFM6IdDValN14Ast__id_info_t1RM8defval_t(&v_50, &v_51);
            FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&f1_0, &v_51, 0), _fx_catch_9);
            FX_CALL(
               _fx_M13Ast_typecheckFM26check_for_duplicate_methodFPv1N14Ast__id_info_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  t_3, &env1_5, sc_1, &di_loc_0, &v_52, 0), _fx_catch_9);
            FX_CALL(
               _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
                  &f_1, &f1_0, &env1_5, &v_52, &env1_6, 0), _fx_catch_9);
            _fx_make_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&f1_0, t_3, &flags_1, &v_53);
            FX_CALL(_fx_cons_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_53, all_members_1, false, &all_members_1),
               _fx_catch_9);
            _fx_make_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&env1_6,
               all_members_1, &v_54);
            _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(
               &__fold_result___4);
            _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_54,
               &__fold_result___4);

         _fx_catch_9: ;
            _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_54);
            _fx_free_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_53);
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_6);
            FX_FREE_FP(&v_52);
            _fx_free_N14Ast__id_info_t(&v_51);
            _fx_free_R13Ast__defval_t(&v_50);
            _fx_free_R16Ast__val_flags_t(&dv_flags_0);
            _fx_free_R16Ast__val_flags_t(&v_49);
            fx_free_exn(&v_48);
            FX_FREE_STR(&v_47);
            FX_FREE_STR(&v_46);
            if (t_3) {
               _fx_free_N10Ast__typ_t(&t_3);
            }
            if (all_members_1) {
               _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&all_members_1);
            }
            _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_5);
            _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_45);
            if (t_2) {
               _fx_free_N10Ast__typ_t(&t_2);
            }
            FX_CHECK_EXN(_fx_catch_11);
         }
         _fx_copy_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___4,
            &v_30);
         FX_COPY_PTR(v_30.t1, &all_members_0);
         _fx_R19Ast__definterface_t* v_57 = &di_0->data;
         _fx_R9Ast__id_t v_58 = ibase_0.di_name;
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t lst_6 = all_members_0;
         for (; lst_6; lst_6 = lst_6->tl) {
            _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t r_0 = 0;
            _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* a_0 = &lst_6->hd;
            FX_COPY_PTR(__fold_result___5, &r_0);
            FX_CALL(_fx_cons_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(a_0, r_0, false, &r_0), _fx_catch_10);
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___5);
            FX_COPY_PTR(r_0, &__fold_result___5);

         _fx_catch_10: ;
            if (r_0) {
               _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&r_0);
            }
            FX_CHECK_EXN(_fx_catch_11);
         }
         FX_COPY_PTR(__fold_result___5, &v_31);
         _fx_make_R19Ast__definterface_t(&v_57->di_name, &v_58, v_57->di_new_methods, v_31, v_57->di_scope, &v_57->di_loc,
            &v_32);
         _fx_R19Ast__definterface_t* v_59 = &di_0->data;
         _fx_free_R19Ast__definterface_t(v_59);
         _fx_copy_R19Ast__definterface_t(&v_32, v_59);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &v_0);

      _fx_catch_11: ;
         _fx_free_R19Ast__definterface_t(&v_32);
         if (v_31) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_31);
         }
         if (__fold_result___5) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___5);
         }
         if (all_members_0) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&all_members_0);
         }
         _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_30);
         _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___4);
         if (base_members_0) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&base_members_0);
         }
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_2);
         _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_29);
         if (v_28) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_28);
         }
         _fx_free_T2Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&__fold_result___3);
         FX_FREE_LIST_SIMPLE(&sc_1);
         if (v_27) {
            _fx_free_N10Ast__typ_t(&v_27);
         }
         if (v_26) {
            _fx_free_N10Ast__typ_t(&v_26);
         }
         _fx_free_R19Ast__definterface_t(&ibase_0);
         if (di_new_methods_0) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&di_new_methods_0);
         }
      }
      else {
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1, &v_0);
      }
      FX_CHECK_EXN(_fx_catch_12);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0, &__fold_result___0);

   _fx_catch_12: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, fx_result);

_fx_cleanup: ;
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM10reg_deffunRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3rR13Ast__deffun_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_rR13Ast__deffun_t_data_t* df_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__exp_t df_body_0 = 0;
   _fx_N10Ast__typ_t df_typ_0 = 0;
   _fx_LN10Ast__pat_t df_args_0 = 0;
   _fx_N10Ast__typ_t rt_0 = 0;
   _fx_LN12Ast__scope_t df_sc_0 = 0;
   _fx_LN10Ast__pat_t df_args_1 = 0;
   _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t __lambda___0 = {0};
   _fx_Nt6option1N10Ast__typ_t classtyp_opt_0 = 0;
   _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB
      __fold_result___0 = {0};
   _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_0 =
      {0};
   _fx_LN10Ast__pat_t args1_0 = 0;
   _fx_LN10Ast__typ_t argtyps1_0 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t temp_env_0 = {0};
   _fx_Rt6Set__t1R9Ast__id_t idset1_0 = {0};
   _fx_Rt6Set__t1R9Ast__id_t templ_args1_0 = {0};
   _fx_N10Ast__pat_t v_1 = 0;
   _fx_N10Ast__pat_t dummy_rt_pat_0 = 0;
   _fx_N10Ast__typ_t v_2 = 0;
   _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_3 = {0};
   _fx_N10Ast__pat_t dummy_rt_pat1_0 = 0;
   _fx_Rt6Set__t1R9Ast__id_t templ_args1_1 = {0};
   _fx_N10Ast__typ_t rt_1 = 0;
   _fx_LN10Ast__typ_t __fold_result___1 = 0;
   _fx_LN10Ast__typ_t v_4 = 0;
   _fx_N10Ast__typ_t df_typ1_0 = 0;
   _fx_FPv1N14Ast__id_info_t v_5 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_0 = {0};
   _fx_Nt11Set__tree_t1R9Ast__id_t v_6 = 0;
   _fx_LR9Ast__id_t df_templ_args_0 = 0;
   _fx_LN10Ast__pat_t __fold_result___2 = 0;
   _fx_LN10Ast__pat_t v_7 = 0;
   _fx_rLR9Ast__id_t v_8 = 0;
   _fx_R13Ast__deffun_t v_9 = {0};
   _fx_N14Ast__id_info_t v_10 = {0};
   fx_exn_t v_11 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_R13Ast__deffun_t* v_12 = &df_0->data;
   _fx_R10Ast__loc_t df_loc_0 = v_12->df_loc;
   _fx_R16Ast__fun_flags_t df_flags_0 = v_12->df_flags;
   FX_COPY_PTR(v_12->df_body, &df_body_0);
   FX_COPY_PTR(v_12->df_typ, &df_typ_0);
   FX_COPY_PTR(v_12->df_args, &df_args_0);
   _fx_R9Ast__id_t df_name_0 = v_12->df_name;
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   _fx_R9Ast__id_t df_name1_0;
   FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, &df_name_0, &df_name1_0, 0), _fx_cleanup);
   if (FX_REC_VARIANT_TAG(df_typ_0) == 14) {
      FX_COPY_PTR(df_typ_0->u.TypFun.t1, &rt_0);
   }
   else {
      fx_exn_t v_13 = {0};
      fx_str_t slit_0 = FX_MAKE_STR("incorrect function type");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &slit_0, &v_13, 0), _fx_catch_0);
      FX_THROW(&v_13, false, _fx_catch_0);

   _fx_catch_0: ;
      fx_free_exn(&v_13);
   }
   FX_CHECK_EXN(_fx_cleanup);
   _fx_N12Ast__scope_t v_14;
   _fx_M3AstFM5ScFunN12Ast__scope_t1RM4id_t(&df_name1_0, &v_14);
   FX_CALL(_fx_cons_LN12Ast__scope_t(&v_14, sc_0, true, &df_sc_0), _fx_cleanup);
   _fx_R9Ast__id_t class_id_0 = df_flags_0.fun_flag_method_of;
   bool res_0;
   FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&class_id_0, &_fx_g9Ast__noid, &res_0, 0), _fx_cleanup);
   if (res_0) {
      FX_COPY_PTR(df_args_0, &df_args_1);
   }
   else {
      _fx_M13Ast_typecheckFM7make_fpFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t1R10Ast__loc_t(&df_loc_0, &__lambda___0);
      FX_CALL(
         _fx_M13Ast_typecheckFM10find_firstNt6option1N10Ast__typ_t6R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t(
            &class_id_0, env_0, env_0, sc_0, &df_loc_0, &__lambda___0, &classtyp_opt_0, 0), _fx_cleanup);
      if ((classtyp_opt_0 != 0) + 1 == 2) {
         _fx_N10Ast__pat_t v_15 = 0;
         _fx_N10Ast__pat_t v_16 = 0;
         FX_CALL(_fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&_fx_g16Ast__std__self__, &df_loc_0, &v_15), _fx_catch_1);
         FX_CALL(
            _fx_M3AstFM8PatTypedN10Ast__pat_t3N10Ast__pat_tN10Ast__typ_tRM5loc_t(v_15, classtyp_opt_0->u.Some, &df_loc_0,
               &v_16), _fx_catch_1);
         FX_CALL(_fx_cons_LN10Ast__pat_t(v_16, df_args_0, true, &df_args_1), _fx_catch_1);

      _fx_catch_1: ;
         if (v_16) {
            _fx_free_N10Ast__pat_t(&v_16);
         }
         if (v_15) {
            _fx_free_N10Ast__pat_t(&v_15);
         }
      }
      else {
         fx_str_t v_17 = {0};
         fx_str_t v_18 = {0};
         fx_exn_t v_19 = {0};
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&class_id_0, &v_17, 0), _fx_catch_2);
         fx_str_t slit_1 = FX_MAKE_STR("no proper class \'");
         fx_str_t slit_2 = FX_MAKE_STR("\' was found for the method");
         {
            const fx_str_t strs_0[] = { slit_1, v_17, slit_2 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &v_18), _fx_catch_2);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &v_18, &v_19, 0), _fx_catch_2);
         FX_THROW(&v_19, false, _fx_catch_2);

      _fx_catch_2: ;
         fx_free_exn(&v_19);
         FX_FREE_STR(&v_18);
         FX_FREE_STR(&v_17);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_make_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
      0, 0, env_0, &_fx_g16Ast__empty_idset, &_fx_g16Ast__empty_idset, true, &__fold_result___0);
   _fx_LN10Ast__pat_t lst_0 = df_args_1;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB
         v_20 = {0};
      _fx_LN10Ast__pat_t args1_1 = 0;
      _fx_LN10Ast__typ_t argtyps1_1 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t temp_env_1 = {0};
      _fx_Rt6Set__t1R9Ast__id_t idset1_1 = {0};
      _fx_Rt6Set__t1R9Ast__id_t templ_args1_2 = {0};
      _fx_N10Ast__typ_t t_0 = 0;
      _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_21 = {0};
      _fx_N10Ast__pat_t arg1_0 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t temp_env_2 = {0};
      _fx_Rt6Set__t1R9Ast__id_t idset1_2 = {0};
      _fx_Rt6Set__t1R9Ast__id_t templ_args1_3 = {0};
      _fx_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t v_22 = {0};
      _fx_N10Ast__typ_t v_23 = 0;
      _fx_N10Ast__pat_t arg1_1 = 0;
      _fx_Nt11Set__tree_t1R9Ast__id_t v_24 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t v_25 = {0};
      _fx_T2Nt11Set__tree_t1R9Ast__id_ti v_26 = {0};
      _fx_Nt11Set__tree_t1R9Ast__id_t t_1 = 0;
      _fx_T2Nt11Set__tree_t1R9Ast__id_tB v_27 = {0};
      _fx_Nt11Set__tree_t1R9Ast__id_t t_2 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t v_28 = {0};
      _fx_Rt6Set__t1R9Ast__id_t templ_args1_4 = {0};
      _fx_N10Ast__pat_t arg1_2 = 0;
      _fx_Rt6Set__t1R9Ast__id_t templ_args1_5 = {0};
      _fx_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB
         v_29 = {0};
      _fx_N10Ast__pat_t arg_0 = lst_0->hd;
      _fx_copy_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
         &__fold_result___0, &v_20);
      FX_COPY_PTR(v_20.t0, &args1_1);
      FX_COPY_PTR(v_20.t1, &argtyps1_1);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_20.t2, &temp_env_1);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_20.t3, &idset1_1);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_20.t4, &templ_args1_2);
      FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&t_0, 0), _fx_catch_4);
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
            arg_0, t_0, &temp_env_1, &idset1_1, &templ_args1_2, df_sc_0, true, true, false, &v_21, 0), _fx_catch_4);
      FX_COPY_PTR(v_21.t0, &arg1_0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_21.t1, &temp_env_2);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_21.t2, &idset1_2);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_21.t3, &templ_args1_3);
      bool typed_0 = v_21.t4;
      if (typed_0) {
         _fx_make_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t(arg1_0, &templ_args1_3, &v_22);
      }
      else {
         _fx_R9Ast__id_t targ_0;
         fx_str_t slit_3 = FX_MAKE_STR("\'targ");
         FX_CALL(_fx_M3AstFM6gen_idRM4id_t2iS(curr_m_idx_0, &slit_3, &targ_0, 0), _fx_catch_4);
         FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, &targ_0, &v_23), _fx_catch_4);
         _fx_R10Ast__loc_t v_30;
         FX_CALL(_fx_M3AstFM11get_pat_locRM5loc_t1N10Ast__pat_t(arg1_0, &v_30, 0), _fx_catch_4);
         FX_CALL(_fx_M3AstFM8PatTypedN10Ast__pat_t3N10Ast__pat_tN10Ast__typ_tRM5loc_t(arg1_0, v_23, &v_30, &arg1_1),
            _fx_catch_4);
         FX_COPY_PTR(templ_args1_3.root, &v_24);
         FX_COPY_FP(&templ_args1_3.cmp, &v_25);
         FX_CALL(
            _fx_M13Ast_typecheckFM12add_to_tree_T2Nt11Set__tree_t1R9Ast__id_ti3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
               v_24, &targ_0, &v_25, &v_26, 0), _fx_catch_4);
         FX_COPY_PTR(v_26.t0, &t_1);
         int_ dsz_0 = v_26.t1;
         if ((t_1 != 0) + 1 == 2) {
            _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_0 = &t_1->u.Node;
            if (vcase_0->t0.tag == 1) {
               _fx_Nt11Set__tree_t1R9Ast__id_t v_31 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                     &_fx_g22Ast_typecheck__Black1_, vcase_0->t1, &vcase_0->t2, vcase_0->t3, &v_31), _fx_catch_3);
               _fx_make_T2Nt11Set__tree_t1R9Ast__id_tB(v_31, false, &v_27);

            _fx_catch_3: ;
               if (v_31) {
                  _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_31);
               }
               goto _fx_endmatch_0;
            }
         }
         _fx_make_T2Nt11Set__tree_t1R9Ast__id_tB(t_1, true, &v_27);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_4);
         FX_COPY_PTR(v_27.t0, &t_2);
         FX_COPY_FP(&templ_args1_3.cmp, &v_28);
         _fx_make_Rt6Set__t1R9Ast__id_t(t_2, templ_args1_3.size + dsz_0, &v_28, &templ_args1_4);
         _fx_make_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t(arg1_1, &templ_args1_4, &v_22);
      }
      FX_COPY_PTR(v_22.t0, &arg1_2);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_22.t1, &templ_args1_5);
      FX_CALL(_fx_cons_LN10Ast__pat_t(arg1_2, args1_1, false, &args1_1), _fx_catch_4);
      FX_CALL(_fx_cons_LN10Ast__typ_t(t_0, argtyps1_1, false, &argtyps1_1), _fx_catch_4);
      _fx_make_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
         args1_1, argtyps1_1, &temp_env_2, &idset1_2, &templ_args1_5, (bool)(v_20.t5 & typed_0), &v_29);
      _fx_free_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
         &__fold_result___0);
      _fx_copy_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
         &v_29, &__fold_result___0);

   _fx_catch_4: ;
      _fx_free_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
         &v_29);
      _fx_free_Rt6Set__t1R9Ast__id_t(&templ_args1_5);
      if (arg1_2) {
         _fx_free_N10Ast__pat_t(&arg1_2);
      }
      _fx_free_Rt6Set__t1R9Ast__id_t(&templ_args1_4);
      FX_FREE_FP(&v_28);
      if (t_2) {
         _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_2);
      }
      _fx_free_T2Nt11Set__tree_t1R9Ast__id_tB(&v_27);
      if (t_1) {
         _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_1);
      }
      _fx_free_T2Nt11Set__tree_t1R9Ast__id_ti(&v_26);
      FX_FREE_FP(&v_25);
      if (v_24) {
         _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_24);
      }
      if (arg1_1) {
         _fx_free_N10Ast__pat_t(&arg1_1);
      }
      if (v_23) {
         _fx_free_N10Ast__typ_t(&v_23);
      }
      _fx_free_T2N10Ast__pat_tRt6Set__t1R9Ast__id_t(&v_22);
      _fx_free_Rt6Set__t1R9Ast__id_t(&templ_args1_3);
      _fx_free_Rt6Set__t1R9Ast__id_t(&idset1_2);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&temp_env_2);
      if (arg1_0) {
         _fx_free_N10Ast__pat_t(&arg1_0);
      }
      _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_21);
      if (t_0) {
         _fx_free_N10Ast__typ_t(&t_0);
      }
      _fx_free_Rt6Set__t1R9Ast__id_t(&templ_args1_2);
      _fx_free_Rt6Set__t1R9Ast__id_t(&idset1_1);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&temp_env_1);
      if (argtyps1_1) {
         _fx_free_LN10Ast__typ_t(&argtyps1_1);
      }
      if (args1_1) {
         _fx_free_LN10Ast__pat_t(&args1_1);
      }
      _fx_free_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
         &v_20);
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_copy_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
      &__fold_result___0, &v_0);
   FX_COPY_PTR(v_0.t0, &args1_0);
   FX_COPY_PTR(v_0.t1, &argtyps1_0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0.t2, &temp_env_0);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&v_0.t3, &idset1_0);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&v_0.t4, &templ_args1_0);
   bool all_typed_0 = v_0.t5;
   if (all_typed_0 == false) {
      if (_fx_g12Options__opt.relax == false) {
         if (sc_0 != 0) {
            if (sc_0->hd.tag == 10) {
               _fx_R9Ast__id_t v_32;
               FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&df_name1_0, &v_32, 0), _fx_cleanup);
               bool res_1;
               FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_32, &_fx_g18Ast__std__lambda__, &res_1, 0), _fx_cleanup);
               if (!res_1) {
                  fx_exn_t v_33 = {0};
                  fx_str_t slit_4 = FX_MAKE_STR("types of all the parameters of global functions must be explicitly specified");
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &slit_4, &v_33, 0), _fx_catch_5);
                  FX_THROW(&v_33, false, _fx_catch_5);

               _fx_catch_5: ;
                  fx_free_exn(&v_33);
                  goto _fx_endmatch_1;
               }
            }
         }
      }
   }

_fx_endmatch_1: ;
   FX_CHECK_EXN(_fx_cleanup);
   FX_CALL(_fx_M3AstFM6PatAnyN10Ast__pat_t1RM5loc_t(&df_loc_0, &v_1), _fx_cleanup);
   FX_CALL(_fx_M3AstFM8PatTypedN10Ast__pat_t3N10Ast__pat_tN10Ast__typ_tRM5loc_t(v_1, rt_0, &df_loc_0, &dummy_rt_pat_0),
      _fx_cleanup);
   FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_2, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
         dummy_rt_pat_0, v_2, &temp_env_0, &idset1_0, &templ_args1_0, df_sc_0, true, true, false, &v_3, 0), _fx_cleanup);
   FX_COPY_PTR(v_3.t0, &dummy_rt_pat1_0);
   _fx_copy_Rt6Set__t1R9Ast__id_t(&v_3.t3, &templ_args1_1);
   if (FX_REC_VARIANT_TAG(dummy_rt_pat1_0) == 9) {
      FX_COPY_PTR(dummy_rt_pat1_0->u.PatTyped.t1, &rt_1);
   }
   else {
      fx_exn_t v_34 = {0};
      fx_str_t slit_5 = FX_MAKE_STR("invalid return pattern after check");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &slit_5, &v_34, 0), _fx_catch_6);
      FX_THROW(&v_34, false, _fx_catch_6);

   _fx_catch_6: ;
      fx_free_exn(&v_34);
   }
   FX_CHECK_EXN(_fx_cleanup);
   _fx_LN10Ast__typ_t lst_1 = argtyps1_0;
   for (; lst_1; lst_1 = lst_1->tl) {
      _fx_LN10Ast__typ_t r_0 = 0;
      _fx_N10Ast__typ_t a_0 = lst_1->hd;
      FX_COPY_PTR(__fold_result___1, &r_0);
      FX_CALL(_fx_cons_LN10Ast__typ_t(a_0, r_0, false, &r_0), _fx_catch_7);
      _fx_free_LN10Ast__typ_t(&__fold_result___1);
      FX_COPY_PTR(r_0, &__fold_result___1);

   _fx_catch_7: ;
      if (r_0) {
         _fx_free_LN10Ast__typ_t(&r_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___1, &v_4);
   FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(v_4, rt_1, &df_typ1_0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM23check_for_duplicate_funFPv1N14Ast__id_info_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
         df_typ1_0, env_0, sc_0, &df_loc_0, &v_5, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
         &df_name_0, &df_name1_0, env_0, &v_5, &env1_0, 0), _fx_cleanup);
   FX_COPY_PTR(templ_args1_1.root, &v_6);
   FX_CALL(
      _fx_M13Ast_typecheckFM12update_list_LR9Ast__id_t2Nt11Set__tree_t1R9Ast__id_tLR9Ast__id_t(v_6, 0, &df_templ_args_0, 0),
      _fx_cleanup);
   _fx_LN10Ast__pat_t lst_2 = args1_0;
   for (; lst_2; lst_2 = lst_2->tl) {
      _fx_LN10Ast__pat_t r_1 = 0;
      _fx_N10Ast__pat_t a_1 = lst_2->hd;
      FX_COPY_PTR(__fold_result___2, &r_1);
      FX_CALL(_fx_cons_LN10Ast__pat_t(a_1, r_1, false, &r_1), _fx_catch_8);
      _fx_free_LN10Ast__pat_t(&__fold_result___2);
      FX_COPY_PTR(r_1, &__fold_result___2);

   _fx_catch_8: ;
      if (r_1) {
         _fx_free_LN10Ast__pat_t(&r_1);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   FX_COPY_PTR(__fold_result___2, &v_7);
   FX_CALL(_fx_make_rLR9Ast__id_t(0, &v_8), _fx_cleanup);
   _fx_make_R13Ast__deffun_t(&df_name1_0, df_templ_args_0, v_7, df_typ1_0, df_body_0, &df_flags_0, sc_0, &df_loc_0, v_8,
      &env1_0, &v_9);
   _fx_R13Ast__deffun_t* v_35 = &df_0->data;
   _fx_free_R13Ast__deffun_t(v_35);
   _fx_copy_R13Ast__deffun_t(&v_9, v_35);
   _fx_M3AstFM5IdFunN14Ast__id_info_t1rRM8deffun_t(df_0, &v_10);
   FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&df_name1_0, &v_10, 0), _fx_cleanup);
   bool v_36;
   if (df_flags_0.fun_flag_ccode) {
      bool v_37; FX_CALL(_fx_M3AstFM12is_fixed_typB1N10Ast__typ_t(rt_1, &v_37, 0), _fx_cleanup); v_36 = !v_37;
   }
   else {
      v_36 = false;
   }
   if (v_36) {
      fx_str_t slit_6 =
         FX_MAKE_STR("return type of @ccode function must be explicitly specified and should not use type vars (\'t etc.)");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &slit_6, &v_11, 0), _fx_cleanup);
      FX_THROW(&v_11, false, _fx_cleanup);
   }
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0, fx_result);

_fx_cleanup: ;
   if (df_body_0) {
      _fx_free_N10Ast__exp_t(&df_body_0);
   }
   if (df_typ_0) {
      _fx_free_N10Ast__typ_t(&df_typ_0);
   }
   if (df_args_0) {
      _fx_free_LN10Ast__pat_t(&df_args_0);
   }
   if (rt_0) {
      _fx_free_N10Ast__typ_t(&rt_0);
   }
   FX_FREE_LIST_SIMPLE(&df_sc_0);
   if (df_args_1) {
      _fx_free_LN10Ast__pat_t(&df_args_1);
   }
   FX_FREE_FP(&__lambda___0);
   if (classtyp_opt_0) {
      _fx_free_Nt6option1N10Ast__typ_t(&classtyp_opt_0);
   }
   _fx_free_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
      &__fold_result___0);
   _fx_free_T6LN10Ast__pat_tLN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(
      &v_0);
   if (args1_0) {
      _fx_free_LN10Ast__pat_t(&args1_0);
   }
   if (argtyps1_0) {
      _fx_free_LN10Ast__typ_t(&argtyps1_0);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&temp_env_0);
   _fx_free_Rt6Set__t1R9Ast__id_t(&idset1_0);
   _fx_free_Rt6Set__t1R9Ast__id_t(&templ_args1_0);
   if (v_1) {
      _fx_free_N10Ast__pat_t(&v_1);
   }
   if (dummy_rt_pat_0) {
      _fx_free_N10Ast__pat_t(&dummy_rt_pat_0);
   }
   if (v_2) {
      _fx_free_N10Ast__typ_t(&v_2);
   }
   _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_3);
   if (dummy_rt_pat1_0) {
      _fx_free_N10Ast__pat_t(&dummy_rt_pat1_0);
   }
   _fx_free_Rt6Set__t1R9Ast__id_t(&templ_args1_1);
   if (rt_1) {
      _fx_free_N10Ast__typ_t(&rt_1);
   }
   if (__fold_result___1) {
      _fx_free_LN10Ast__typ_t(&__fold_result___1);
   }
   if (v_4) {
      _fx_free_LN10Ast__typ_t(&v_4);
   }
   if (df_typ1_0) {
      _fx_free_N10Ast__typ_t(&df_typ1_0);
   }
   FX_FREE_FP(&v_5);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0);
   if (v_6) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_6);
   }
   FX_FREE_LIST_SIMPLE(&df_templ_args_0);
   if (__fold_result___2) {
      _fx_free_LN10Ast__pat_t(&__fold_result___2);
   }
   if (v_7) {
      _fx_free_LN10Ast__pat_t(&v_7);
   }
   if (v_8) {
      _fx_free_rLR9Ast__id_t(&v_8);
   }
   _fx_free_R13Ast__deffun_t(&v_9);
   _fx_free_N14Ast__id_info_t(&v_10);
   fx_free_exn(&v_11);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM10__lambda__Nt6option1N10Ast__typ_t1N16Ast__env_entry_t(
   struct _fx_N16Ast__env_entry_t_data_t* e_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM10__lambda__Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM10__lambda__Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t*)fx_fv;
   _fx_R10Ast__loc_t* df_loc_0 = &cv_0->t0;
   int tag_0 = FX_REC_VARIANT_TAG(e_0);
   if (tag_0 == 1) {
      if (e_0->u.EnvId.m == 0) {
         FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, fx_result); goto _fx_endmatch_1;
      }
   }
   if (tag_0 == 1) {
      _fx_N14Ast__id_info_t info_0 = {0};
      _fx_R17Ast__defvariant_t v_0 = {0};
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&e_0->u.EnvId, df_loc_0, &info_0, 0), _fx_catch_3);
      int tag_1 = info_0.tag;
      if (tag_1 == 6) {
         _fx_copy_R17Ast__defvariant_t(&info_0.u.IdVariant->data, &v_0);
         if (v_0.dvar_flags.var_flag_class_from > 0) {
            _fx_LN10Ast__typ_t templ_args_0 = 0;
            _fx_LR9Ast__id_t dvar_templ_args_0 = 0;
            _fx_N10Ast__typ_t v_1 = 0;
            _fx_LN10Ast__typ_t lstend_0 = 0;
            FX_COPY_PTR(v_0.dvar_templ_args, &dvar_templ_args_0);
            _fx_LR9Ast__id_t lst_0 = dvar_templ_args_0;
            for (; lst_0; lst_0 = lst_0->tl) {
               _fx_N10Ast__typ_t res_0 = 0;
               _fx_R9Ast__id_t* i_0 = &lst_0->hd;
               _fx_R9Ast__id_t v_2;
               FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(i_0, &v_2, 0), _fx_catch_0);
               FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, &v_2, &res_0), _fx_catch_0);
               _fx_LN10Ast__typ_t node_0 = 0;
               FX_CALL(_fx_cons_LN10Ast__typ_t(res_0, 0, false, &node_0), _fx_catch_0);
               FX_LIST_APPEND(templ_args_0, lstend_0, node_0);

            _fx_catch_0: ;
               if (res_0) {
                  _fx_free_N10Ast__typ_t(&res_0);
               }
               FX_CHECK_EXN(_fx_catch_1);
            }
            _fx_R9Ast__id_t v_3;
            FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&v_0.dvar_name, &v_3, 0), _fx_catch_1);
            FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(templ_args_0, &v_3, &v_1), _fx_catch_1);
            FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(v_1, fx_result), _fx_catch_1);

         _fx_catch_1: ;
            if (v_1) {
               _fx_free_N10Ast__typ_t(&v_1);
            }
            FX_FREE_LIST_SIMPLE(&dvar_templ_args_0);
            if (templ_args_0) {
               _fx_free_LN10Ast__typ_t(&templ_args_0);
            }
            goto _fx_endmatch_0;
         }
      }
      bool res_1;
      if (tag_1 == 6) {
         res_1 = true;
      }
      else if (tag_1 == 7) {
         res_1 = true;
      }
      else if (tag_1 == 5) {
         res_1 = true;
      }
      else {
         res_1 = false;
      }
      FX_CHECK_EXN(_fx_catch_3);
      if (res_1) {
         fx_str_t v_4 = {0};
         fx_str_t v_5 = {0};
         fx_exn_t v_6 = {0};
         _fx_R10Ast__loc_t loc_0;
         FX_CALL(_fx_M3AstFM14get_idinfo_locRM5loc_t1N14Ast__id_info_t(&info_0, &loc_0, 0), _fx_catch_2);
         FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(&loc_0, &v_4, 0), _fx_catch_2);
         fx_str_t slit_0 =
            FX_MAKE_STR(
               "the type name specified before the method name should reference a class; instead, it references the type defined at ");
         {
            const fx_str_t strs_0[] = { slit_0, v_4 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_0, 2, &v_5), _fx_catch_2);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(df_loc_0, &v_5, &v_6, 0), _fx_catch_2);
         FX_THROW(&v_6, false, _fx_catch_2);

      _fx_catch_2: ;
         fx_free_exn(&v_6);
         FX_FREE_STR(&v_5);
         FX_FREE_STR(&v_4);
         goto _fx_endmatch_0;
      }
      FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, fx_result);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_3);

   _fx_catch_3: ;
      _fx_free_R17Ast__defvariant_t(&v_0);
      _fx_free_N14Ast__id_info_t(&info_0);
      goto _fx_endmatch_1;
   }
   if (tag_0 == 2) {
      fx_str_t v_7 = {0};
      fx_str_t v_8 = {0};
      fx_exn_t v_9 = {0};
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(e_0->u.EnvTyp, &v_7, 0), _fx_catch_4);
      fx_str_t slit_1 =
         FX_MAKE_STR(
            "the type name specified before the method name should reference a class; instead, it references the temporary type \'");
      fx_str_t slit_2 = FX_MAKE_STR("\'");
      {
         const fx_str_t strs_1[] = { slit_1, v_7, slit_2 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_1, 3, &v_8), _fx_catch_4);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(df_loc_0, &v_8, &v_9, 0), _fx_catch_4);
      FX_THROW(&v_9, false, _fx_catch_4);

   _fx_catch_4: ;
      fx_free_exn(&v_9);
      FX_FREE_STR(&v_8);
      FX_FREE_STR(&v_7);
      goto _fx_endmatch_1;
   }
   FX_FAST_THROW(FX_EXN_NoMatchError, _fx_cleanup);

_fx_endmatch_1: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM7make_fpFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t1R10Ast__loc_t(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM10__lambda__Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t, fx_free,
      _fx_M13Ast_typecheckFM10__lambda__Nt6option1N10Ast__typ_t1N16Ast__env_entry_t);
   fcv->t0 = *arg0;
   return 0;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12check_defexnRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3rR13Ast__defexn_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
   struct _fx_rR13Ast__defexn_t_data_t* de_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t t_0 = 0;
   _fx_N10Ast__typ_t t_1 = 0;
   _fx_N10Ast__typ_t ftyp_0 = 0;
   _fx_R13Ast__defexn_t v_0 = {0};
   _fx_N14Ast__id_info_t v_1 = {0};
   fx_str_t v_2 = {0};
   _fx_FPv1N14Ast__id_info_t v_3 = {0};
   int fx_status = 0;
   _fx_R13Ast__defexn_t* v_4 = &de_0->data;
   _fx_R10Ast__loc_t loc_0 = v_4->dexn_loc;
   FX_COPY_PTR(v_4->dexn_typ, &t_0);
   _fx_R9Ast__id_t n0_0 = v_4->dexn_name;
   int_ curr_m_idx_0;
   if (sc_0 != 0) {
      _fx_N12Ast__scope_t* v_5 = &sc_0->hd;
      if (v_5->tag == 10) {
         curr_m_idx_0 = v_5->u.ScModule; goto _fx_endmatch_0;
      }
   }
   fx_exn_t v_6 = {0};
   fx_str_t slit_0 = FX_MAKE_STR("exceptions can only be defined at a module level");
   FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&loc_0, &slit_0, &v_6, 0), _fx_catch_0);
   FX_THROW(&v_6, false, _fx_catch_0);

_fx_catch_0: ;
   fx_free_exn(&v_6);

_fx_endmatch_0: ;
   FX_CHECK_EXN(_fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
         t_0, env_0, sc_0, &loc_0, &t_1, 0), _fx_cleanup);
   _fx_R9Ast__id_t n_0;
   FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, &n0_0, &n_0, 0), _fx_cleanup);
   if (FX_REC_VARIANT_TAG(t_1) == 13) {
      FX_COPY_PTR(_fx_g21Ast_typecheck__TypExn, &ftyp_0);
   }
   else {
      _fx_LN10Ast__typ_t v_7 = 0;
      if (FX_REC_VARIANT_TAG(t_1) == 17) {
         FX_COPY_PTR(t_1->u.TypTuple, &v_7);
      }
      else {
         FX_CALL(_fx_cons_LN10Ast__typ_t(t_1, 0, true, &v_7), _fx_catch_1);  _fx_catch_1: ;
      }
      FX_CHECK_EXN(_fx_catch_2);
      FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(v_7, _fx_g21Ast_typecheck__TypExn, &ftyp_0),
         _fx_catch_2);

   _fx_catch_2: ;
      if (v_7) {
         _fx_free_LN10Ast__typ_t(&v_7);
      }
   }
   FX_CHECK_EXN(_fx_cleanup);
   _fx_make_R13Ast__defexn_t(&n_0, t_1, sc_0, &loc_0, &v_0);
   _fx_R13Ast__defexn_t* v_8 = &de_0->data;
   _fx_free_R13Ast__defexn_t(v_8);
   _fx_copy_R13Ast__defexn_t(&v_0, v_8);
   _fx_M3AstFM5IdExnN14Ast__id_info_t1rRM8defexn_t(de_0, &v_1);
   FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&n_0, &v_1, 0), _fx_cleanup);
   if (sc_0 != 0) {
      _fx_N12Ast__scope_t* v_9 = &sc_0->hd;
      if (v_9->tag == 10) {
         _fx_R9Ast__id_t v_10;
         FX_CALL(_fx_M3AstFM15get_module_nameRM4id_t1i(v_9->u.ScModule, &v_10, 0), _fx_cleanup);
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_10, &v_2, 0), _fx_cleanup);
         fx_str_t slit_1 = FX_MAKE_STR("Builtins");
         if (_fx_F6__eq__B2SS(&v_2, &slit_1, 0)) {
            _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_11 = 0;
            _fx_FPi2R9Ast__id_tR9Ast__id_t v_12 = {0};
            _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_13 = 0;
            _fx_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB v_14 = {0};
            _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t new_root_0 = 0;
            _fx_FPi2R9Ast__id_tR9Ast__id_t v_15 = {0};
            _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t v_16 = {0};
            _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_17 = 0;
            _fx_FPi2R9Ast__id_tR9Ast__id_t v_18 = {0};
            _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_19 = 0;
            _fx_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB v_20 = {0};
            _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t new_root_1 = 0;
            _fx_FPi2R9Ast__id_tR9Ast__id_t v_21 = {0};
            _fx_Rt6Map__t2R9Ast__id_tR9Ast__id_t v_22 = {0};
            FX_COPY_PTR(_fx_g23Ast__builtin_exceptions.root, &v_11);
            FX_COPY_FP(&_fx_g23Ast__builtin_exceptions.cmp, &v_12);
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  v_11, &n0_0, &n_0, &v_12, &v_13, 0), _fx_catch_5);
            if ((v_13 != 0) + 1 == 2) {
               _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
                  vcase_0 = &v_13->u.Node;
               if (vcase_0->t0.tag == 1) {
                  _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_23 = 0;
                  FX_CALL(
                     _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                        &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, &vcase_0->t3, vcase_0->t4, &v_23),
                     _fx_catch_3);
                  _fx_make_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(v_23, false, &v_14);

               _fx_catch_3: ;
                  if (v_23) {
                     _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_23);
                  }
                  goto _fx_endmatch_1;
               }
            }
            _fx_make_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(v_13, true, &v_14);

         _fx_endmatch_1: ;
            FX_CHECK_EXN(_fx_catch_5);
            FX_COPY_PTR(v_14.t0, &new_root_0);
            FX_COPY_FP(&_fx_g23Ast__builtin_exceptions.cmp, &v_15);
            _fx_make_Rt6Map__t2R9Ast__id_tR9Ast__id_t(new_root_0, &v_15, &v_16);
            _fx_free_Rt6Map__t2R9Ast__id_tR9Ast__id_t(&_fx_g23Ast__builtin_exceptions);
            _fx_copy_Rt6Map__t2R9Ast__id_tR9Ast__id_t(&v_16, &_fx_g23Ast__builtin_exceptions);
            FX_COPY_PTR(_fx_g23Ast__builtin_exceptions.root, &v_17);
            FX_COPY_FP(&_fx_g23Ast__builtin_exceptions.cmp, &v_18);
            FX_CALL(
               _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t4Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
                  v_17, &n_0, &n0_0, &v_18, &v_19, 0), _fx_catch_5);
            if ((v_19 != 0) + 1 == 2) {
               _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t*
                  vcase_1 = &v_19->u.Node;
               if (vcase_1->t0.tag == 1) {
                  _fx_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t v_24 = 0;
                  FX_CALL(
                     _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tR9Ast__id_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_tR9Ast__id_tR9Ast__id_tNt11Map__tree_t2R9Ast__id_tR9Ast__id_t(
                        &_fx_g20Ast_typecheck__Black, vcase_1->t1, &vcase_1->t2, &vcase_1->t3, vcase_1->t4, &v_24),
                     _fx_catch_4);
                  _fx_make_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(v_24, false, &v_20);

               _fx_catch_4: ;
                  if (v_24) {
                     _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_24);
                  }
                  goto _fx_endmatch_2;
               }
            }
            _fx_make_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(v_19, true, &v_20);

         _fx_endmatch_2: ;
            FX_CHECK_EXN(_fx_catch_5);
            FX_COPY_PTR(v_20.t0, &new_root_1);
            FX_COPY_FP(&_fx_g23Ast__builtin_exceptions.cmp, &v_21);
            _fx_make_Rt6Map__t2R9Ast__id_tR9Ast__id_t(new_root_1, &v_21, &v_22);
            _fx_free_Rt6Map__t2R9Ast__id_tR9Ast__id_t(&_fx_g23Ast__builtin_exceptions);
            _fx_copy_Rt6Map__t2R9Ast__id_tR9Ast__id_t(&v_22, &_fx_g23Ast__builtin_exceptions);

         _fx_catch_5: ;
            _fx_free_Rt6Map__t2R9Ast__id_tR9Ast__id_t(&v_22);
            FX_FREE_FP(&v_21);
            if (new_root_1) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&new_root_1);
            }
            _fx_free_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(&v_20);
            if (v_19) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_19);
            }
            FX_FREE_FP(&v_18);
            if (v_17) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_17);
            }
            _fx_free_Rt6Map__t2R9Ast__id_tR9Ast__id_t(&v_16);
            FX_FREE_FP(&v_15);
            if (new_root_0) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&new_root_0);
            }
            _fx_free_T2Nt11Map__tree_t2R9Ast__id_tR9Ast__id_tB(&v_14);
            if (v_13) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_13);
            }
            FX_FREE_FP(&v_12);
            if (v_11) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tR9Ast__id_t(&v_11);
            }
            goto _fx_endmatch_3;
         }
      }
   }

_fx_endmatch_3: ;
   FX_CHECK_EXN(_fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM23check_for_duplicate_funFPv1N14Ast__id_info_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
         ftyp_0, env_0, sc_0, &loc_0, &v_3, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM19add_id_to_env_checkRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tFPv1N14Ast__id_info_t(
         &n0_0, &n_0, env_0, &v_3, fx_result, 0), _fx_cleanup);

_fx_cleanup: ;
   if (t_0) {
      _fx_free_N10Ast__typ_t(&t_0);
   }
   if (t_1) {
      _fx_free_N10Ast__typ_t(&t_1);
   }
   if (ftyp_0) {
      _fx_free_N10Ast__typ_t(&ftyp_0);
   }
   _fx_free_R13Ast__defexn_t(&v_0);
   _fx_free_N14Ast__id_info_t(&v_1);
   FX_FREE_STR(&v_2);
   FX_FREE_FP(&v_3);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM12check_deffunrR13Ast__deffun_t2rR13Ast__deffun_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_rR13Ast__deffun_t_data_t* df_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_rR13Ast__deffun_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t df_typ_0 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_R13Ast__deffun_t* v_0 = &df_0->data;
   _fx_R10Ast__loc_t df_loc_0 = v_0->df_loc;
   FX_COPY_PTR(v_0->df_typ, &df_typ_0);
   FX_CALL(
      _fx_M13Ast_typecheckFM15instantiate_funrR13Ast__deffun_t5rR13Ast__deffun_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tB(
         df_0, df_typ_0, env_0, &df_loc_0, false, fx_result, 0), _fx_cleanup);

_fx_cleanup: ;
   if (df_typ_0) {
      _fx_free_N10Ast__typ_t(&df_typ_0);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM30check_typ_and_collect_typ_varsT2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t6N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tNt6option1rRt6Set__t1R9Ast__id_tLN12Ast__scope_tR10Ast__loc_tB(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t* r_opt_typ_vars_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   bool process_default_0,
   struct _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t r_env_ref_0 = 0;
   _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t check_typ__0 = {0};
   _fx_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t v_0 = 0;
   _fx_R16Ast__ast_callb_t callb_0 = {0};
   _fx_N10Ast__typ_t v_1 = 0;
   int fx_status = 0;
   FX_CALL(_fx_make_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &r_env_ref_0), _fx_cleanup);
   _fx_M13Ast_typecheckFM7make_fpFPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tNt6option1rRt6Set__t1R9Ast__id_tLN12Ast__scope_t(
      env_0, loc_0, process_default_0, r_env_ref_0, r_opt_typ_vars_0, sc_0, &check_typ__0);
   FX_CALL(
      _fx_M13Ast_typecheckFM4SomeNt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
         &check_typ__0, &v_0), _fx_cleanup);
   _fx_make_R16Ast__ast_callb_t(v_0, _fx_g21Ast_typecheck__None8_, _fx_g21Ast_typecheck__None7_, &callb_0);
   FX_CALL(check_typ__0.fp(t_0, &callb_0, &v_1, check_typ__0.fcv), _fx_cleanup);
   _fx_make_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_1, &r_env_ref_0->data, fx_result);

_fx_cleanup: ;
   if (r_env_ref_0) {
      _fx_free_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&r_env_ref_0);
   }
   FX_FREE_FP(&check_typ__0);
   if (v_0) {
      _fx_free_Nt6option1FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(&v_0);
   }
   _fx_free_R16Ast__ast_callb_t(&callb_0);
   if (v_1) {
      _fx_free_N10Ast__typ_t(&v_1);
   }
   return fx_status;
}

static int _fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R16Ast__ast_callb_t* callb_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t*)fx_fv;
   _fx_R10Ast__loc_t* loc_0 = &cv_0->t1;
   _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t r_env_ref_0 = cv_0->t3;
   _fx_Nt6option1rRt6Set__t1R9Ast__id_t* r_opt_typ_vars_0 = &cv_0->t4;
   _fx_LN12Ast__scope_t sc_0 = cv_0->t5;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* r_env_0 = &r_env_ref_0->data;
   int tag_0 = FX_REC_VARIANT_TAG(t_0);
   if (tag_0 == 24) {
      _fx_LN10Ast__typ_t ty_args_0 = 0;
      _fx_LN10Ast__typ_t ty_args_1 = 0;
      _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t __lambda___0 = {0};
      _fx_Nt6option1N10Ast__typ_t found_typ_opt_0 = 0;
      fx_str_t v_0 = {0};
      _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_0 = &t_0->u.TypApp;
      _fx_R9Ast__id_t* n_0 = &vcase_0->t1;
      _fx_LN10Ast__typ_t lstend_0 = 0;
      FX_COPY_PTR(vcase_0->t0, &ty_args_1);
      _fx_LN10Ast__typ_t lst_0 = ty_args_1;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_N10Ast__typ_t res_0 = 0;
         _fx_N10Ast__typ_t t_1 = lst_0->hd;
         FX_CALL(_fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(t_1, callb_0, &res_0, fx_fv),
            _fx_catch_0);
         _fx_LN10Ast__typ_t node_0 = 0;
         FX_CALL(_fx_cons_LN10Ast__typ_t(res_0, 0, false, &node_0), _fx_catch_0);
         FX_LIST_APPEND(ty_args_0, lstend_0, node_0);

      _fx_catch_0: ;
         if (res_0) {
            _fx_free_N10Ast__typ_t(&res_0);
         }
         FX_CHECK_EXN(_fx_catch_4);
      }
      bool __fold_result___0 = true;
      _fx_LN10Ast__typ_t lst_1 = ty_args_0;
      for (; lst_1; lst_1 = lst_1->tl) {
         _fx_N10Ast__typ_t a_0 = lst_1->hd;
         bool v_1;
         FX_CALL(_fx_M13Ast_typecheckFM11is_real_typB1N10Ast__typ_t(a_0, &v_1, 0), _fx_catch_1);
         if (!v_1) {
            __fold_result___0 = false; FX_BREAK(_fx_catch_1);
         }

      _fx_catch_1: ;
         FX_CHECK_BREAK();
         FX_CHECK_EXN(_fx_catch_4);
      }
      bool ty_args_are_real_0 = __fold_result___0;
      _fx_M13Ast_typecheckFM7make_fpFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t7R10Ast__loc_tR9Ast__id_trRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tN10Ast__typ_tLN10Ast__typ_tB(
         loc_0, n_0, r_env_ref_0, sc_0, t_0, ty_args_0, ty_args_are_real_0, &__lambda___0);
      FX_CALL(
         _fx_M13Ast_typecheckFM10find_firstNt6option1N10Ast__typ_t6R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_tFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t(
            n_0, r_env_0, r_env_0, sc_0, loc_0, &__lambda___0, &found_typ_opt_0, 0), _fx_catch_4);
      if ((found_typ_opt_0 != 0) + 1 == 2) {
         FX_COPY_PTR(found_typ_opt_0->u.Some, fx_result); goto _fx_endmatch_0;
      }
      if (ty_args_0 == 0) {
         if (r_opt_typ_vars_0->tag == 2) {
            _fx_rRt6Set__t1R9Ast__id_t r_typ_vars_0 = r_opt_typ_vars_0->u.Some;
            FX_CALL(_fx_M3AstFM6stringS1RM4id_t(n_0, &v_0, 0), _fx_catch_4);
            fx_str_t slit_0 = FX_MAKE_STR("\'");
            if (_fx_M6StringFM10startswithB2SS(&v_0, &slit_0, 0)) {
               _fx_Rt6Set__t1R9Ast__id_t v_2 = {0};
               _fx_Rt6Set__t1R9Ast__id_t v_3 = {0};
               _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_4 = {0};
               _fx_copy_Rt6Set__t1R9Ast__id_t(&r_typ_vars_0->data, &v_2);
               FX_CALL(_fx_M13Ast_typecheckFM3addRt6Set__t1R9Ast__id_t2Rt6Set__t1R9Ast__id_tR9Ast__id_t(&v_2, n_0, &v_3, 0),
                  _fx_catch_2);
               _fx_Rt6Set__t1R9Ast__id_t* v_5 = &r_typ_vars_0->data;
               _fx_free_Rt6Set__t1R9Ast__id_t(v_5);
               _fx_copy_Rt6Set__t1R9Ast__id_t(&v_3, v_5);
               FX_CALL(
                  _fx_M13Ast_typecheckFM14add_typ_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
                     n_0, t_0, r_env_0, &v_4, 0), _fx_catch_2);
               _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(r_env_0);
               _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_4, r_env_0);
               FX_COPY_PTR(t_0, fx_result);

            _fx_catch_2: ;
               _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_4);
               _fx_free_Rt6Set__t1R9Ast__id_t(&v_3);
               _fx_free_Rt6Set__t1R9Ast__id_t(&v_2);
               goto _fx_endmatch_0;
            }
         }
      }
      fx_str_t v_6 = {0};
      fx_str_t v_7 = {0};
      fx_exn_t v_8 = {0};
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n_0, &v_6, 0), _fx_catch_3);
      fx_str_t slit_1 = FX_MAKE_STR("the appropriate match for \'");
      fx_str_t slit_2 = FX_MAKE_STR("\' is not found");
      {
         const fx_str_t strs_0[] = { slit_1, v_6, slit_2 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &v_7), _fx_catch_3);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_7, &v_8, 0), _fx_catch_3);
      FX_THROW(&v_8, false, _fx_catch_3);

   _fx_catch_3: ;
      fx_free_exn(&v_8);
      FX_FREE_STR(&v_7);
      FX_FREE_STR(&v_6);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_catch_4);

   _fx_catch_4: ;
      FX_FREE_STR(&v_0);
      if (found_typ_opt_0) {
         _fx_free_Nt6option1N10Ast__typ_t(&found_typ_opt_0);
      }
      FX_FREE_FP(&__lambda___0);
      if (ty_args_1) {
         _fx_free_LN10Ast__typ_t(&ty_args_1);
      }
      if (ty_args_0) {
         _fx_free_LN10Ast__typ_t(&ty_args_0);
      }
   }
   else if (tag_0 == 2) {
      if (r_opt_typ_vars_0->tag == 2) {
         _fx_Rt6Set__t1R9Ast__id_t v_9 = {0};
         _fx_Rt6Set__t1R9Ast__id_t v_10 = {0};
         _fx_rRt6Set__t1R9Ast__id_t r_typ_vars_1 = r_opt_typ_vars_0->u.Some;
         _fx_copy_Rt6Set__t1R9Ast__id_t(&r_typ_vars_1->data, &v_9);
         _fx_R9Ast__id_t v_11;
         fx_str_t slit_3 = FX_MAKE_STR("__var_tuple__");
         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&slit_3, &v_11, 0), _fx_catch_5);
         FX_CALL(_fx_M13Ast_typecheckFM3addRt6Set__t1R9Ast__id_t2Rt6Set__t1R9Ast__id_tR9Ast__id_t(&v_9, &v_11, &v_10, 0),
            _fx_catch_5);
         _fx_Rt6Set__t1R9Ast__id_t* v_12 = &r_typ_vars_1->data;
         _fx_free_Rt6Set__t1R9Ast__id_t(v_12);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_10, v_12);

      _fx_catch_5: ;
         _fx_free_Rt6Set__t1R9Ast__id_t(&v_10);
         _fx_free_Rt6Set__t1R9Ast__id_t(&v_9);
      }
      FX_CHECK_EXN(_fx_catch_6);
      FX_CALL(_fx_M3AstFM8walk_typN10Ast__typ_t2N10Ast__typ_tRM11ast_callb_t(t_0, callb_0, fx_result, 0), _fx_catch_6);

   _fx_catch_6: ;
   }
   else if (tag_0 == 3) {
      if (r_opt_typ_vars_0->tag == 2) {
         _fx_Rt6Set__t1R9Ast__id_t v_13 = {0};
         _fx_Rt6Set__t1R9Ast__id_t v_14 = {0};
         _fx_rRt6Set__t1R9Ast__id_t r_typ_vars_2 = r_opt_typ_vars_0->u.Some;
         _fx_copy_Rt6Set__t1R9Ast__id_t(&r_typ_vars_2->data, &v_13);
         _fx_R9Ast__id_t v_15;
         fx_str_t slit_4 = FX_MAKE_STR("__var_array__");
         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&slit_4, &v_15, 0), _fx_catch_7);
         FX_CALL(_fx_M13Ast_typecheckFM3addRt6Set__t1R9Ast__id_t2Rt6Set__t1R9Ast__id_tR9Ast__id_t(&v_13, &v_15, &v_14, 0),
            _fx_catch_7);
         _fx_Rt6Set__t1R9Ast__id_t* v_16 = &r_typ_vars_2->data;
         _fx_free_Rt6Set__t1R9Ast__id_t(v_16);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_14, v_16);

      _fx_catch_7: ;
         _fx_free_Rt6Set__t1R9Ast__id_t(&v_14);
         _fx_free_Rt6Set__t1R9Ast__id_t(&v_13);
      }
      FX_CHECK_EXN(_fx_catch_8);
      FX_CALL(_fx_M3AstFM8walk_typN10Ast__typ_t2N10Ast__typ_tRM11ast_callb_t(t_0, callb_0, fx_result, 0), _fx_catch_8);

   _fx_catch_8: ;
   }
   else if (tag_0 == 4) {
      if (r_opt_typ_vars_0->tag == 2) {
         _fx_Rt6Set__t1R9Ast__id_t v_17 = {0};
         _fx_Rt6Set__t1R9Ast__id_t v_18 = {0};
         _fx_rRt6Set__t1R9Ast__id_t r_typ_vars_3 = r_opt_typ_vars_0->u.Some;
         _fx_copy_Rt6Set__t1R9Ast__id_t(&r_typ_vars_3->data, &v_17);
         _fx_R9Ast__id_t v_19;
         fx_str_t slit_5 = FX_MAKE_STR("__var_record__");
         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&slit_5, &v_19, 0), _fx_catch_9);
         FX_CALL(_fx_M13Ast_typecheckFM3addRt6Set__t1R9Ast__id_t2Rt6Set__t1R9Ast__id_tR9Ast__id_t(&v_17, &v_19, &v_18, 0),
            _fx_catch_9);
         _fx_Rt6Set__t1R9Ast__id_t* v_20 = &r_typ_vars_3->data;
         _fx_free_Rt6Set__t1R9Ast__id_t(v_20);
         _fx_copy_Rt6Set__t1R9Ast__id_t(&v_18, v_20);

      _fx_catch_9: ;
         _fx_free_Rt6Set__t1R9Ast__id_t(&v_18);
         _fx_free_Rt6Set__t1R9Ast__id_t(&v_17);
      }
      FX_CHECK_EXN(_fx_catch_10);
      FX_CALL(_fx_M3AstFM8walk_typN10Ast__typ_t2N10Ast__typ_tRM11ast_callb_t(t_0, callb_0, fx_result, 0), _fx_catch_10);

   _fx_catch_10: ;
   }
   else if (tag_0 == 20) {
      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_21 = {0};
      _fx_LR9Ast__id_t v_22 = 0;
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_0 = 0;
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_23 = 0;
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_1 = 0;
      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_24 = {0};
      _fx_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_25 = 0;
      _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&t_0->u.TypRecord->data, &v_21);
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_2 = v_21.t0;
      _fx_LR9Ast__id_t lstend_1 = 0;
      FX_COPY_PTR(relems_2, &relems_0);
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_2 = relems_0;
      for (; lst_2; lst_2 = lst_2->tl) {
         _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___0 = &lst_2->hd;
         _fx_LR9Ast__id_t node_1 = 0;
         FX_CALL(_fx_cons_LR9Ast__id_t(&__pat___0->t1, 0, false, &node_1), _fx_catch_11);
         FX_LIST_APPEND(v_22, lstend_1, node_1);

      _fx_catch_11: ;
         FX_CHECK_EXN(_fx_catch_14);
      }
      FX_CALL(_fx_M13Ast_typecheckFM30check_for_rec_field_duplicatesv2LR9Ast__id_tR10Ast__loc_t(v_22, loc_0, 0), _fx_catch_14);
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lstend_2 = 0;
      FX_COPY_PTR(relems_2, &relems_1);
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_3 = relems_1;
      for (; lst_3; lst_3 = lst_3->tl) {
         _fx_R16Ast__val_flags_t flags_0 = {0};
         _fx_N10Ast__typ_t t_2 = 0;
         _fx_N10Ast__exp_t v0_0 = 0;
         _fx_N10Ast__typ_t t_3 = 0;
         _fx_N10Ast__exp_t v0_1 = 0;
         _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t tup_0 = {0};
         _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___1 = &lst_3->hd;
         _fx_copy_R16Ast__val_flags_t(&__pat___1->t0, &flags_0);
         _fx_R9Ast__id_t n_1 = __pat___1->t1;
         FX_COPY_PTR(__pat___1->t2, &t_2);
         FX_COPY_PTR(__pat___1->t3, &v0_0);
         FX_CALL(_fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t(t_2, callb_0, &t_3, fx_fv),
            _fx_catch_13);
         if (!cv_0->t2) {
            FX_COPY_PTR(v0_0, &v0_1);
         }
         else {
            if (FX_REC_VARIANT_TAG(v0_0) == 1) {
               FX_COPY_PTR(v0_0, &v0_1);
            }
            else {
               _fx_T2N10Ast__typ_tR10Ast__loc_t v_26 = {0};
               _fx_N10Ast__typ_t t0_0 = 0;
               FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(v0_0, &v_26, 0), _fx_catch_12);
               FX_COPY_PTR(v_26.t0, &t0_0);
               _fx_R10Ast__loc_t loc0_0 = v_26.t1;
               fx_str_t slit_6 = FX_MAKE_STR("the actual and the specified default parameter types do not match");
               FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t_3, t0_0, &loc0_0, &slit_6, 0),
                  _fx_catch_12);
               FX_CALL(
                  _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                     v0_0, &cv_0->t0, sc_0, &v0_1, 0), _fx_catch_12);

            _fx_catch_12: ;
               if (t0_0) {
                  _fx_free_N10Ast__typ_t(&t0_0);
               }
               _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_26);
            }
            FX_CHECK_EXN(_fx_catch_13);
         }
         _fx_make_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&flags_0, &n_1, t_3, v0_1, &tup_0);
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t node_2 = 0;
         FX_CALL(_fx_cons_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&tup_0, 0, false, &node_2), _fx_catch_13);
         FX_LIST_APPEND(v_23, lstend_2, node_2);

      _fx_catch_13: ;
         _fx_free_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&tup_0);
         if (v0_1) {
            _fx_free_N10Ast__exp_t(&v0_1);
         }
         if (t_3) {
            _fx_free_N10Ast__typ_t(&t_3);
         }
         if (v0_0) {
            _fx_free_N10Ast__exp_t(&v0_0);
         }
         if (t_2) {
            _fx_free_N10Ast__typ_t(&t_2);
         }
         _fx_free_R16Ast__val_flags_t(&flags_0);
         FX_CHECK_EXN(_fx_catch_14);
      }
      _fx_make_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(v_23, v_21.t1, &v_24);
      FX_CALL(_fx_make_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_24, &v_25), _fx_catch_14);
      FX_CALL(_fx_M3AstFM9TypRecordN10Ast__typ_t1rT2LT4RM11val_flags_tRM4id_tN10Ast__typ_tN10Ast__exp_tB(v_25, fx_result),
         _fx_catch_14);

   _fx_catch_14: ;
      if (v_25) {
         _fx_free_rT2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_25);
      }
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_24);
      if (relems_1) {
         _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_1);
      }
      if (v_23) {
         _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_23);
      }
      if (relems_0) {
         _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_0);
      }
      FX_FREE_LIST_SIMPLE(&v_22);
      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(&v_21);
   }
   else {
      FX_CALL(_fx_M3AstFM8walk_typN10Ast__typ_t2N10Ast__typ_tRM11ast_callb_t(t_0, callb_0, fx_result, 0), _fx_catch_15);

   _fx_catch_15: ;
   }

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t6Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tNt6option1rRt6Set__t1R9Ast__id_tLN12Ast__scope_t(
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* arg0,
   struct _fx_R10Ast__loc_t* arg1,
   bool arg2,
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* arg3,
   struct _fx_Nt6option1rRt6Set__t1R9Ast__id_t* arg4,
   struct _fx_LN12Ast__scope_t_data_t* arg5,
   struct _fx_FPN10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t_cldata_t,
      _fx_free_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t,
      _fx_M13Ast_typecheckFM10check_typ_N10Ast__typ_t2N10Ast__typ_tR16Ast__ast_callb_t);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(arg0, &fcv->t0);
   fcv->t1 = *arg1;
   fcv->t2 = arg2;
   FX_COPY_PTR(arg3, &fcv->t3);
   _fx_copy_Nt6option1rRt6Set__t1R9Ast__id_t(arg4, &fcv->t4);
   FX_COPY_PTR(arg5, &fcv->t5);
   return 0;
}

static int _fx_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t(
   struct _fx_N16Ast__env_entry_t_data_t* entry_0,
   struct _fx_Nt6option1N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   _fx_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t* cv_0 =
      (_fx_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t*)fx_fv;
   _fx_R10Ast__loc_t* loc_0 = &cv_0->t0;
   _fx_R9Ast__id_t* n_0 = &cv_0->t1;
   _fx_LN12Ast__scope_t sc_0 = cv_0->t3;
   _fx_LN10Ast__typ_t ty_args_0 = cv_0->t5;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* r_env_0 = &cv_0->t2->data;
   int tag_0 = FX_REC_VARIANT_TAG(entry_0);
   if (tag_0 == 2) {
      fx_str_t v_0 = {0};
      fx_str_t v_1 = {0};
      fx_exn_t v_2 = {0};
      if (ty_args_0 == 0) {
         FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(entry_0->u.EnvTyp, fx_result), _fx_catch_0);
      }
      else {
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n_0, &v_0, 0), _fx_catch_0);
         fx_str_t slit_0 = FX_MAKE_STR("a concrete type \'");
         fx_str_t slit_1 = FX_MAKE_STR("\' cannot be further instantiated");
         {
            const fx_str_t strs_0[] = { slit_0, v_0, slit_1 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &v_1), _fx_catch_0);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_1, &v_2, 0), _fx_catch_0);
         FX_THROW(&v_2, false, _fx_catch_0);
      }

   _fx_catch_0: ;
      fx_free_exn(&v_2);
      FX_FREE_STR(&v_1);
      FX_FREE_STR(&v_0);
      goto _fx_endmatch_2;
   }
   if (tag_0 == 1) {
      if (entry_0->u.EnvId.m == 0) {
         FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, fx_result); goto _fx_endmatch_2;
      }
   }
   if (tag_0 == 1) {
      _fx_N14Ast__id_info_t v_3 = {0};
      _fx_R9Ast__id_t* i_0 = &entry_0->u.EnvId;
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(i_0, loc_0, &v_3, 0), _fx_catch_10);
      int tag_1 = v_3.tag;
      bool res_0;
      if (tag_1 == 1) {
         res_0 = true;
      }
      else if (tag_1 == 2) {
         res_0 = true;
      }
      else if (tag_1 == 3) {
         res_0 = true;
      }
      else if (tag_1 == 4) {
         res_0 = true;
      }
      else if (tag_1 == 8) {
         res_0 = true;
      }
      else {
         res_0 = false;
      }
      FX_CHECK_EXN(_fx_catch_10);
      if (res_0) {
         FX_COPY_PTR(_fx_g22Ast_typecheck__None11_, fx_result); goto _fx_endmatch_1;
      }
      if (tag_1 == 7) {
         _fx_R19Ast__definterface_t v_4 = {0};
         _fx_N10Ast__typ_t v_5 = 0;
         fx_str_t v_6 = {0};
         fx_str_t v_7 = {0};
         fx_exn_t v_8 = {0};
         _fx_copy_R19Ast__definterface_t(&v_3.u.IdInterface->data, &v_4);
         if (ty_args_0 == 0) {
            FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, &v_4.di_name, &v_5), _fx_catch_1);
            FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(v_5, fx_result), _fx_catch_1);
         }
         else {
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(n_0, &v_6, 0), _fx_catch_1);
            fx_str_t slit_2 = FX_MAKE_STR("a concrete interface type \'");
            fx_str_t slit_3 = FX_MAKE_STR("\' cannot be further instantiated");
            {
               const fx_str_t strs_1[] = { slit_2, v_6, slit_3 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_1, 3, &v_7), _fx_catch_1);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_7, &v_8, 0), _fx_catch_1);
            FX_THROW(&v_8, false, _fx_catch_1);
         }

      _fx_catch_1: ;
         fx_free_exn(&v_8);
         FX_FREE_STR(&v_7);
         FX_FREE_STR(&v_6);
         if (v_5) {
            _fx_free_N10Ast__typ_t(&v_5);
         }
         _fx_free_R19Ast__definterface_t(&v_4);
         goto _fx_endmatch_1;
      }
      if (tag_1 == 5) {
         _fx_N10Ast__typ_t dt_typ_0 = 0;
         _fx_LR9Ast__id_t dt_templ_args_0 = 0;
         fx_str_t v_9 = {0};
         fx_str_t v_10 = {0};
         fx_exn_t v_11 = {0};
         _fx_LN10Ast__typ_t norm_ty_args_0 = 0;
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_0 = {0};
         _fx_N10Ast__typ_t v_12 = 0;
         _fx_N10Ast__typ_t v_13 = 0;
         _fx_R13Ast__deftyp_t* v_14 = &v_3.u.IdTyp->data;
         _fx_R10Ast__loc_t dt_loc_0 = v_14->dt_loc;
         bool dt_finalized_0 = v_14->dt_finalized;
         FX_COPY_PTR(v_14->dt_typ, &dt_typ_0);
         FX_COPY_PTR(v_14->dt_templ_args, &dt_templ_args_0);
         _fx_R9Ast__id_t dt_name_0 = v_14->dt_name;
         if (!dt_finalized_0) {
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&dt_name_0, &v_9, 0), _fx_catch_4);
            fx_str_t slit_4 = FX_MAKE_STR("later declared non-variant type \'");
            fx_str_t slit_5 = FX_MAKE_STR("\' is referenced; try to reorder the type declarations");
            {
               const fx_str_t strs_2[] = { slit_4, v_9, slit_5 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_2, 3, &v_10), _fx_catch_4);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_10, &v_11, 0), _fx_catch_4);
            FX_THROW(&v_11, false, _fx_catch_4);
         }
         bool res_1;
         FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&dt_name_0, n_0, &res_1, 0), _fx_catch_4);
         bool t_0;
         if (res_1) {
            t_0 = ty_args_0 == 0;
         }
         else {
            t_0 = false;
         }
         if (t_0) {
            FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(cv_0->t4, fx_result), _fx_catch_4);
         }
         else {
            FX_CALL(
               _fx_M13Ast_typecheckFM21check_and_norm_tyargsLN10Ast__typ_t4LN10Ast__typ_tLR9Ast__id_tR10Ast__loc_tR10Ast__loc_t(
                  ty_args_0, dt_templ_args_0, &dt_loc_0, loc_0, &norm_ty_args_0, 0), _fx_catch_4);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(r_env_0, &__fold_result___0);
            _fx_LR9Ast__id_t lst_0 = dt_templ_args_0;
            _fx_LN10Ast__typ_t lst_1 = norm_ty_args_0;
            for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl) {
               _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_0 = {0};
               _fx_LN16Ast__env_entry_t entries_0 = 0;
               _fx_N16Ast__env_entry_t v_15 = 0;
               _fx_LN16Ast__env_entry_t v_16 = 0;
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_17 = 0;
               _fx_FPi2R9Ast__id_tR9Ast__id_t v_18 = {0};
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_19 = 0;
               _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_20 = {0};
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
               _fx_FPi2R9Ast__id_tR9Ast__id_t v_21 = {0};
               _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_22 = {0};
               _fx_N10Ast__typ_t t_1 = lst_1->hd;
               _fx_R9Ast__id_t* n_1 = &lst_0->hd;
               _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_0);
               FX_CALL(
                  _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(n_1,
                     &env_0, &entries_0, 0), _fx_catch_3);
               FX_CALL(_fx_M3AstFM6EnvTypN16Ast__env_entry_t1N10Ast__typ_t(t_1, &v_15), _fx_catch_3);
               FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_15, entries_0, true, &v_16), _fx_catch_3);
               FX_COPY_PTR(env_0.root, &v_17);
               FX_COPY_FP(&env_0.cmp, &v_18);
               FX_CALL(
                  _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
                     v_17, n_1, v_16, &v_18, &v_19, 0), _fx_catch_3);
               if ((v_19 != 0) + 1 == 2) {
                  _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
                     vcase_0 = &v_19->u.Node;
                  if (vcase_0->t0.tag == 1) {
                     _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_23 = 0;
                     FX_CALL(
                        _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                           &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_23),
                        _fx_catch_2);
                     _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_23, false, &v_20);

                  _fx_catch_2: ;
                     if (v_23) {
                        _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_23);
                     }
                     goto _fx_endmatch_0;
                  }
               }
               _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_19, true, &v_20);

            _fx_endmatch_0: ;
               FX_CHECK_EXN(_fx_catch_3);
               FX_COPY_PTR(v_20.t0, &new_root_0);
               FX_COPY_FP(&env_0.cmp, &v_21);
               _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_21, &v_22);
               _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
               _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_22, &__fold_result___0);

            _fx_catch_3: ;
               _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_22);
               FX_FREE_FP(&v_21);
               if (new_root_0) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
               }
               _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_20);
               if (v_19) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_19);
               }
               FX_FREE_FP(&v_18);
               if (v_17) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_17);
               }
               if (v_16) {
                  _fx_free_LN16Ast__env_entry_t(&v_16);
               }
               if (v_15) {
                  _fx_free_N16Ast__env_entry_t(&v_15);
               }
               if (entries_0) {
                  _fx_free_LN16Ast__env_entry_t(&entries_0);
               }
               _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_0);
               FX_CHECK_EXN(_fx_catch_4);
            }
            int s_0 = !lst_0 + !lst_1;
            FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_4);
            _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env1_0);
            FX_CALL(_fx_M3AstFM7dup_typN10Ast__typ_t1N10Ast__typ_t(dt_typ_0, &v_12, 0), _fx_catch_4);
            FX_CALL(
               _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                  v_12, &env1_0, sc_0, loc_0, &v_13, 0), _fx_catch_4);
            FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(v_13, fx_result), _fx_catch_4);
         }

      _fx_catch_4: ;
         if (v_13) {
            _fx_free_N10Ast__typ_t(&v_13);
         }
         if (v_12) {
            _fx_free_N10Ast__typ_t(&v_12);
         }
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
         if (norm_ty_args_0) {
            _fx_free_LN10Ast__typ_t(&norm_ty_args_0);
         }
         fx_free_exn(&v_11);
         FX_FREE_STR(&v_10);
         FX_FREE_STR(&v_9);
         FX_FREE_LIST_SIMPLE(&dt_templ_args_0);
         if (dt_typ_0) {
            _fx_free_N10Ast__typ_t(&dt_typ_0);
         }
         goto _fx_endmatch_1;
      }
      if (tag_1 == 6) {
         _fx_rLR9Ast__id_t dvar_templ_inst_0 = 0;
         _fx_N10Ast__typ_t dvar_alias_0 = 0;
         _fx_LR9Ast__id_t dvar_templ_args_0 = 0;
         _fx_N10Ast__typ_t v_24 = 0;
         _fx_N10Ast__typ_t t1_0 = 0;
         _fx_LR9Ast__id_t v_25 = 0;
         _fx_rR17Ast__defvariant_t dvar_0 = v_3.u.IdVariant;
         _fx_R17Ast__defvariant_t* v_26 = &dvar_0->data;
         _fx_R10Ast__loc_t dvar_loc_0 = v_26->dvar_loc;
         FX_COPY_PTR(v_26->dvar_templ_inst, &dvar_templ_inst_0);
         FX_COPY_PTR(v_26->dvar_alias, &dvar_alias_0);
         FX_COPY_PTR(v_26->dvar_templ_args, &dvar_templ_args_0);
         _fx_R9Ast__id_t dvar_name_0 = v_26->dvar_name;
         if (dvar_templ_args_0 == 0) {
            FX_COPY_PTR(dvar_alias_0, &v_24);
         }
         else if (cv_0->t6) {
            FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(ty_args_0, &dvar_name_0, &t1_0), _fx_catch_9);
            FX_COPY_PTR(dvar_templ_inst_0->data, &v_25);
            _fx_Nt6option1R9Ast__id_t __fold_result___1 = _fx_g21Ast_typecheck__None9_;
            _fx_LR9Ast__id_t lst_2 = v_25;
            for (; lst_2; lst_2 = lst_2->tl) {
               _fx_N14Ast__id_info_t v_27 = {0};
               _fx_R9Ast__id_t* a_0 = &lst_2->hd;
               FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(a_0, &dvar_loc_0, &v_27, 0), _fx_catch_7);
               bool v_28;
               if (v_27.tag == 6) {
                  _fx_N10Ast__typ_t dvar_inst_alias_0 = 0;
                  FX_COPY_PTR(v_27.u.IdVariant->data.dvar_alias, &dvar_inst_alias_0);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(t1_0, dvar_inst_alias_0,
                        &dvar_loc_0, true, &v_28, 0), _fx_catch_5);

               _fx_catch_5: ;
                  if (dvar_inst_alias_0) {
                     _fx_free_N10Ast__typ_t(&dvar_inst_alias_0);
                  }
               }
               else {
                  fx_str_t v_29 = {0};
                  fx_str_t v_30 = {0};
                  fx_exn_t v_31 = {0};
                  FX_CALL(_fx_M3AstFM6stringS1RM4id_t(i_0, &v_29, 0), _fx_catch_6);
                  fx_str_t slit_6 = FX_MAKE_STR("invalid type of variant instance ");
                  fx_str_t slit_7 = FX_MAKE_STR(" (must be also a variant)");
                  {
                     const fx_str_t strs_3[] = { slit_6, v_29, slit_7 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_3, 3, &v_30), _fx_catch_6);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_30, &v_31, 0), _fx_catch_6);
                  FX_THROW(&v_31, false, _fx_catch_6);

               _fx_catch_6: ;
                  fx_free_exn(&v_31);
                  FX_FREE_STR(&v_30);
                  FX_FREE_STR(&v_29);
               }
               FX_CHECK_EXN(_fx_catch_7);
               if (v_28) {
                  _fx_Nt6option1R9Ast__id_t v_32;
                  _fx_M13Ast_typecheckFM4SomeNt6option1R9Ast__id_t1R9Ast__id_t(a_0, &v_32);
                  __fold_result___1 = v_32;
                  FX_BREAK(_fx_catch_7);
               }

            _fx_catch_7: ;
               _fx_free_N14Ast__id_info_t(&v_27);
               FX_CHECK_BREAK();
               FX_CHECK_EXN(_fx_catch_9);
            }
            _fx_Nt6option1R9Ast__id_t v_33 = __fold_result___1;
            if (v_33.tag == 2) {
               FX_COPY_PTR(t1_0, &v_24);
            }
            else {
               _fx_T2R9Ast__id_tN10Ast__typ_t v_34 = {0};
               FX_CALL(
                  _fx_M13Ast_typecheckFM19instantiate_variantT2R9Ast__id_tN10Ast__typ_t5LN10Ast__typ_trR17Ast__defvariant_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
                     ty_args_0, dvar_0, r_env_0, sc_0, loc_0, &v_34, 0), _fx_catch_8);
               FX_COPY_PTR(v_34.t1, &v_24);

            _fx_catch_8: ;
               _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_34);
            }
            FX_CHECK_EXN(_fx_catch_9);
         }
         else {
            FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(ty_args_0, &dvar_name_0, &v_24), _fx_catch_9);
         }
         FX_CALL(_fx_M13Ast_typecheckFM4SomeNt6option1N10Ast__typ_t1N10Ast__typ_t(v_24, fx_result), _fx_catch_9);

      _fx_catch_9: ;
         FX_FREE_LIST_SIMPLE(&v_25);
         if (t1_0) {
            _fx_free_N10Ast__typ_t(&t1_0);
         }
         if (v_24) {
            _fx_free_N10Ast__typ_t(&v_24);
         }
         FX_FREE_LIST_SIMPLE(&dvar_templ_args_0);
         if (dvar_alias_0) {
            _fx_free_N10Ast__typ_t(&dvar_alias_0);
         }
         if (dvar_templ_inst_0) {
            _fx_free_rLR9Ast__id_t(&dvar_templ_inst_0);
         }
         goto _fx_endmatch_1;
      }
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_10);

   _fx_endmatch_1: ;
      FX_CHECK_EXN(_fx_catch_10);

   _fx_catch_10: ;
      _fx_free_N14Ast__id_info_t(&v_3);
      goto _fx_endmatch_2;
   }
   FX_FAST_THROW(FX_EXN_NoMatchError, _fx_cleanup);

_fx_endmatch_2: ;

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPNt6option1N10Ast__typ_t1N16Ast__env_entry_t7R10Ast__loc_tR9Ast__id_trRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tN10Ast__typ_tLN10Ast__typ_tB(
   struct _fx_R10Ast__loc_t* arg0,
   struct _fx_R9Ast__id_t* arg1,
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* arg2,
   struct _fx_LN12Ast__scope_t_data_t* arg3,
   struct _fx_N10Ast__typ_t_data_t* arg4,
   struct _fx_LN10Ast__typ_t_data_t* arg5,
   bool arg6,
   struct _fx_FPNt6option1N10Ast__typ_t1N16Ast__env_entry_t* fx_result)
{
   FX_MAKE_FP_IMPL_START(_fx_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t_cldata_t,
      _fx_free_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t,
      _fx_M13Ast_typecheckFM12__lambda__1_Nt6option1N10Ast__typ_t1N16Ast__env_entry_t);
   fcv->t0 = *arg0;
   fcv->t1 = *arg1;
   FX_COPY_PTR(arg2, &fcv->t2);
   FX_COPY_PTR(arg3, &fcv->t3);
   FX_COPY_PTR(arg4, &fcv->t4);
   FX_COPY_PTR(arg5, &fcv->t5);
   fcv->t6 = arg6;
   return 0;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_N10Ast__typ_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_0 = {0};
   int fx_status = 0;
   FX_CALL(
      _fx_M13Ast_typecheckFM30check_typ_and_collect_typ_varsT2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t6N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tNt6option1rRt6Set__t1R9Ast__id_tLN12Ast__scope_tR10Ast__loc_tB(
         t_0, env_0, &_fx_g21Ast_typecheck__None5_, sc_0, loc_0, false, &v_0, 0), _fx_cleanup);
   FX_COPY_PTR(v_0.t0, fx_result);

_fx_cleanup: ;
   _fx_free_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM15instantiate_funrR13Ast__deffun_t5rR13Ast__deffun_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tB(
   struct _fx_rR13Ast__deffun_t_data_t* templ_df_0,
   struct _fx_N10Ast__typ_t_data_t* inst_ftyp_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* inst_env0_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   bool instantiate_0,
   struct _fx_rR13Ast__deffun_t_data_t** fx_result,
   void* fx_fv)
{
   fx_str_t v_0 = {0};
   fx_str_t v_1 = {0};
   fx_str_t v_2 = {0};
   _fx_LS v_3 = 0;
   _fx_N10Ast__typ_t v_4 = 0;
   _fx_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t v_5 = {0};
   _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t v_6 = 0;
   fx_exn_t exn_0 = {0};
   _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t v_7 = 0;
   _fx_LS v_8 = 0;
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_R9Ast__id_t df_name_0 = templ_df_0->data.df_name;
   if (instantiate_0) {
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&df_name_0, &v_0, 0), _fx_cleanup);
      FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(inst_loc_0, &v_1, 0), _fx_cleanup);
      fx_str_t slit_0 = FX_MAKE_STR("when instantiating \'");
      fx_str_t slit_1 = FX_MAKE_STR("\' at ");
      {
         const fx_str_t strs_0[] = { slit_0, v_0, slit_1, v_1 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_0, 4, &v_2), _fx_cleanup);
      }
      FX_CALL(_fx_cons_LS(&v_2, _fx_g24Ast__all_compile_err_ctx, true, &v_3), _fx_cleanup);
      _fx_free_LS(&_fx_g24Ast__all_compile_err_ctx);
      FX_COPY_PTR(v_3, &_fx_g24Ast__all_compile_err_ctx);
   }
   FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_4, 0), _fx_cleanup);
   _fx_make_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&df_name_0, v_4, inst_loc_0, &v_5);
   FX_CALL(_fx_cons_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&v_5, _fx_g17Ast__all_func_ctx, true, &v_6), _fx_cleanup);
   _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&_fx_g17Ast__all_func_ctx);
   FX_COPY_PTR(v_6, &_fx_g17Ast__all_func_ctx);
   _fx_rR13Ast__deffun_t inst_df_0 = 0;
   _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t v_9 = 0;
   _fx_LS v_10 = 0;
   FX_CALL(
      _fx_M13Ast_typecheckFM16instantiate_fun_rR13Ast__deffun_t5rR13Ast__deffun_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tB(
         templ_df_0, inst_ftyp_0, inst_env0_0, inst_loc_0, instantiate_0, &inst_df_0, 0), _fx_catch_0);
   if (_fx_g17Ast__all_func_ctx != 0) {
      FX_COPY_PTR(_fx_g17Ast__all_func_ctx->tl, &v_9);
   }
   else {
      FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_0);
   }
   FX_CHECK_EXN(_fx_catch_0);
   _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&_fx_g17Ast__all_func_ctx);
   FX_COPY_PTR(v_9, &_fx_g17Ast__all_func_ctx);
   if (instantiate_0) {
      if (_fx_g24Ast__all_compile_err_ctx != 0) {
         FX_COPY_PTR(_fx_g24Ast__all_compile_err_ctx->tl, &v_10);
      }
      else {
         FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_0);
      }
      FX_CHECK_EXN(_fx_catch_0);
      _fx_free_LS(&_fx_g24Ast__all_compile_err_ctx);
      FX_COPY_PTR(v_10, &_fx_g24Ast__all_compile_err_ctx);
   }
   FX_COPY_PTR(inst_df_0, fx_result);

_fx_catch_0: ;
   if (inst_df_0) {
      _fx_free_rR13Ast__deffun_t(&inst_df_0);
   }
   if (v_9) {
      _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&v_9);
   }
   if (v_10) {
      _fx_free_LS(&v_10);
   }
   if (fx_status < 0) {
      fx_exn_get_and_reset(fx_status, &exn_0);
      fx_status = 0;
      if (*fx_result) {
         _fx_free_rR13Ast__deffun_t(fx_result);
      }
      if (_fx_g17Ast__all_func_ctx != 0) {
         FX_COPY_PTR(_fx_g17Ast__all_func_ctx->tl, &v_7);
      }
      else {
         FX_FAST_THROW(FX_EXN_NullListError, _fx_cleanup);
      }
      FX_CHECK_EXN(_fx_cleanup);
      _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&_fx_g17Ast__all_func_ctx);
      FX_COPY_PTR(v_7, &_fx_g17Ast__all_func_ctx);
      if (instantiate_0) {
         if (_fx_g24Ast__all_compile_err_ctx != 0) {
            FX_COPY_PTR(_fx_g24Ast__all_compile_err_ctx->tl, &v_8);
         }
         else {
            FX_FAST_THROW(FX_EXN_NullListError, _fx_cleanup);
         }
         FX_CHECK_EXN(_fx_cleanup);
         _fx_free_LS(&_fx_g24Ast__all_compile_err_ctx);
         FX_COPY_PTR(v_8, &_fx_g24Ast__all_compile_err_ctx);
      }
      FX_THROW(&exn_0, false, _fx_cleanup);
   }

_fx_cleanup: ;
   FX_FREE_STR(&v_0);
   FX_FREE_STR(&v_1);
   FX_FREE_STR(&v_2);
   if (v_3) {
      _fx_free_LS(&v_3);
   }
   if (v_4) {
      _fx_free_N10Ast__typ_t(&v_4);
   }
   _fx_free_T3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&v_5);
   if (v_6) {
      _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&v_6);
   }
   fx_free_exn(&exn_0);
   if (v_7) {
      _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&v_7);
   }
   if (v_8) {
      _fx_free_LS(&v_8);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM16instantiate_fun_rR13Ast__deffun_t5rR13Ast__deffun_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tB(
   struct _fx_rR13Ast__deffun_t_data_t* templ_df_0,
   struct _fx_N10Ast__typ_t_data_t* inst_ftyp_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* inst_env0_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   bool instantiate_0,
   struct _fx_rR13Ast__deffun_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_LN12Ast__scope_t df_scope_0 = 0;
   _fx_N10Ast__exp_t df_body_0 = 0;
   _fx_LN10Ast__pat_t df_args_0 = 0;
   fx_str_t v_0 = {0};
   fx_str_t v_1 = {0};
   fx_exn_t v_2 = {0};
   _fx_N10Ast__typ_t inst_ftyp_1 = 0;
   _fx_T2LN10Ast__typ_tN10Ast__typ_t v_3 = {0};
   _fx_LN10Ast__typ_t arg_typs_0 = 0;
   _fx_N10Ast__typ_t rt_0 = 0;
   _fx_LN10Ast__typ_t arg_typs_1 = 0;
   _fx_N10Ast__typ_t v_4 = 0;
   _fx_LN12Ast__scope_t fun_sc_0 = 0;
   _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t __fold_result___0 = {0};
   _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_5 = {0};
   _fx_LN10Ast__pat_t df_inst_args_0 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t inst_env_0 = {0};
   _fx_LN10Ast__pat_t df_inst_args_1 = 0;
   _fx_N10Ast__typ_t rt_1 = 0;
   _fx_N10Ast__exp_t inst_body_0 = 0;
   _fx_T2N10Ast__typ_tR10Ast__loc_t v_6 = {0};
   _fx_N10Ast__typ_t body_typ_0 = 0;
   _fx_N10Ast__typ_t inst_ftyp_2 = 0;
   _fx_rLR9Ast__id_t v_7 = 0;
   _fx_R13Ast__deffun_t v_8 = {0};
   _fx_rR13Ast__deffun_t inst_df_0 = 0;
   _fx_N14Ast__id_info_t v_9 = {0};
   _fx_rLR9Ast__id_t v_10 = 0;
   _fx_LR9Ast__id_t v_11 = 0;
   _fx_rLR9Ast__id_t v_12 = 0;
   _fx_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t all_func_ctx_0 = 0;
   _fx_N10Ast__exp_t inst_body_1 = 0;
   _fx_N10Ast__typ_t v_13 = 0;
   _fx_N10Ast__typ_t inst_ftyp_3 = 0;
   _fx_LN10Ast__typ_t arg_typs_2 = 0;
   _fx_T2rR17Ast__defvariant_tN10Ast__typ_t v_14 = {0};
   _fx_rR17Ast__defvariant_t dvar_0 = 0;
   _fx_N10Ast__typ_t mtyp_0 = 0;
   _fx_LT2R9Ast__id_tLTa2R9Ast__id_t v_15 = 0;
   _fx_LT2R9Ast__id_tLTa2R9Ast__id_t dvar_ifaces_0 = 0;
   _fx_R17Ast__defvariant_t v_16 = {0};
   _fx_R13Ast__deffun_t v_17 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_R13Ast__deffun_t* v_18 = &templ_df_0->data;
   _fx_R10Ast__loc_t df_loc_0 = v_18->df_loc;
   FX_COPY_PTR(v_18->df_scope, &df_scope_0);
   _fx_R16Ast__fun_flags_t df_flags_0 = v_18->df_flags;
   FX_COPY_PTR(v_18->df_body, &df_body_0);
   FX_COPY_PTR(v_18->df_args, &df_args_0);
   _fx_R9Ast__id_t df_name_0 = v_18->df_name;
   bool is_constr_0;
   FX_CALL(_fx_M3AstFM14is_constructorB1RM11fun_flags_t(&df_flags_0, &is_constr_0, 0), _fx_cleanup);
   if (is_constr_0) {
      FX_CALL(_fx_M3AstFM6stringS1RM4id_t(&df_name_0, &v_0, 0), _fx_cleanup);
      fx_str_t slit_0 = FX_MAKE_STR("internal error: attempt to instantiate constructor \'");
      fx_str_t slit_1 =
         FX_MAKE_STR("\'. It should be instantiated in a different way. Try to use explicit type specification somewhere");
      {
         const fx_str_t strs_0[] = { slit_0, v_0, slit_1 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &v_1), _fx_cleanup);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &v_1, &v_2, 0), _fx_cleanup);
      FX_THROW(&v_2, false, _fx_cleanup);
   }
   int_ nargs_0;
   FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__pat_t(df_args_0, &nargs_0, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(inst_ftyp_0, &inst_ftyp_1, 0), _fx_cleanup);
   int tag_0 = FX_REC_VARIANT_TAG(inst_ftyp_1);
   if (tag_0 == 14) {
      _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_0 = &inst_ftyp_1->u.TypFun;
      _fx_LN10Ast__typ_t v_19 = vcase_0->t0;
      if (v_19 != 0) {
         if (v_19->tl == 0) {
            if (FX_REC_VARIANT_TAG(v_19->hd) == 13) {
               _fx_make_T2LN10Ast__typ_tN10Ast__typ_t(0, vcase_0->t1, &v_3); goto _fx_endmatch_0;
            }
         }
      }
   }
   if (tag_0 == 14) {
      _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_1 = &inst_ftyp_1->u.TypFun;
      _fx_make_T2LN10Ast__typ_tN10Ast__typ_t(vcase_1->t0, vcase_1->t1, &v_3);
      goto _fx_endmatch_0;
   }
   fx_exn_t v_20 = {0};
   if (is_constr_0) {
      _fx_make_T2LN10Ast__typ_tN10Ast__typ_t(0, inst_ftyp_1, &v_3);
   }
   else {
      fx_str_t slit_2 = FX_MAKE_STR("internal error: the type of instantiated function is not a function");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &slit_2, &v_20, 0), _fx_catch_0);
      FX_THROW(&v_20, false, _fx_catch_0);
   }

_fx_catch_0: ;
   fx_free_exn(&v_20);

_fx_endmatch_0: ;
   FX_CHECK_EXN(_fx_cleanup);
   FX_COPY_PTR(v_3.t0, &arg_typs_0);
   FX_COPY_PTR(v_3.t1, &rt_0);
   int_ ninst_args_0;
   FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(arg_typs_0, &ninst_args_0, 0), _fx_cleanup);
   if (nargs_0 == ninst_args_0) {
      FX_COPY_PTR(arg_typs_0, &arg_typs_1);
   }
   else if (nargs_0 == 1) {
      FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(arg_typs_0, &v_4), _fx_cleanup);
      FX_CALL(_fx_cons_LN10Ast__typ_t(v_4, 0, true, &arg_typs_1), _fx_cleanup);
   }
   else {
      if (arg_typs_0 != 0) {
         if (arg_typs_0->tl == 0) {
            _fx_N10Ast__typ_t v_21 = arg_typs_0->hd;
            if (FX_REC_VARIANT_TAG(v_21) == 17) {
               _fx_LN10Ast__typ_t elems_0 = v_21->u.TypTuple;
               int_ v_22;
               FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(elems_0, &v_22, 0), _fx_cleanup);
               if (v_22 == nargs_0) {
                  FX_COPY_PTR(elems_0, &arg_typs_1); goto _fx_endmatch_1;
               }
            }
         }
      }
      fx_str_t v_23 = {0};
      fx_str_t v_24 = {0};
      fx_str_t v_25 = {0};
      fx_str_t v_26 = {0};
      fx_exn_t v_27 = {0};
      FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(inst_loc_0, &v_23, 0), _fx_catch_1);
      FX_CALL(_fx_F6stringS1i(ninst_args_0, &v_24, 0), _fx_catch_1);
      FX_CALL(_fx_F6stringS1i(nargs_0, &v_25, 0), _fx_catch_1);
      fx_str_t slit_3 = FX_MAKE_STR("during instantion at ");
      fx_str_t slit_4 = FX_MAKE_STR(": incorrect number of actual parameters = \'");
      fx_str_t slit_5 = FX_MAKE_STR("\' (vs expected ");
      fx_str_t slit_6 = FX_MAKE_STR(")");
      {
         const fx_str_t strs_1[] = { slit_3, v_23, slit_4, v_24, slit_5, v_25, slit_6 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_1, 7, &v_26), _fx_catch_1);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &v_26, &v_27, 0), _fx_catch_1);
      FX_THROW(&v_27, false, _fx_catch_1);

   _fx_catch_1: ;
      fx_free_exn(&v_27);
      FX_FREE_STR(&v_26);
      FX_FREE_STR(&v_25);
      FX_FREE_STR(&v_24);
      FX_FREE_STR(&v_23);

   _fx_endmatch_1: ;
      FX_CHECK_EXN(_fx_cleanup);
   }
   _fx_R9Ast__id_t inst_name_0;
   if (instantiate_0) {
      int_ v_28;
      FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(df_scope_0, &v_28, 0), _fx_cleanup);
      FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(v_28, &df_name_0, &inst_name_0, 0), _fx_cleanup);
   }
   else {
      inst_name_0 = df_name_0;
   }
   _fx_N12Ast__scope_t v_29;
   _fx_M3AstFM5ScFunN12Ast__scope_t1RM4id_t(&inst_name_0, &v_29);
   FX_CALL(_fx_cons_LN12Ast__scope_t(&v_29, df_scope_0, true, &fun_sc_0), _fx_cleanup);
   _fx_make_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(0, inst_env0_0,
      &_fx_g16Ast__empty_idset, &__fold_result___0);
   _fx_LN10Ast__pat_t lst_0 = df_args_0;
   _fx_LN10Ast__typ_t lst_1 = arg_typs_1;
   for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl) {
      _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_30 = {0};
      _fx_LN10Ast__pat_t df_inst_args_2 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t inst_env_1 = {0};
      _fx_Rt6Set__t1R9Ast__id_t tmp_idset_0 = {0};
      _fx_N10Ast__pat_t v_31 = 0;
      _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_32 = {0};
      _fx_N10Ast__pat_t df_inst_arg_0 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t inst_env_2 = {0};
      _fx_Rt6Set__t1R9Ast__id_t tmp_idset_1 = {0};
      _fx_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t v_33 = {0};
      _fx_N10Ast__typ_t arg_typ_0 = lst_1->hd;
      _fx_N10Ast__pat_t df_arg_0 = lst_0->hd;
      _fx_copy_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&__fold_result___0, &v_30);
      FX_COPY_PTR(v_30.t0, &df_inst_args_2);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_30.t1, &inst_env_1);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_30.t2, &tmp_idset_0);
      FX_CALL(_fx_M3AstFM7dup_patN10Ast__pat_t1N10Ast__pat_t(df_arg_0, &v_31, 0), _fx_catch_2);
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
            v_31, arg_typ_0, &inst_env_1, &tmp_idset_0, &_fx_g16Ast__empty_idset, fun_sc_0, false, true, false, &v_32, 0),
         _fx_catch_2);
      FX_COPY_PTR(v_32.t0, &df_inst_arg_0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_32.t1, &inst_env_2);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_32.t2, &tmp_idset_1);
      FX_CALL(_fx_cons_LN10Ast__pat_t(df_inst_arg_0, df_inst_args_2, false, &df_inst_args_2), _fx_catch_2);
      _fx_make_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(df_inst_args_2, &inst_env_2,
         &tmp_idset_1, &v_33);
      _fx_free_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&__fold_result___0);
      _fx_copy_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_33, &__fold_result___0);

   _fx_catch_2: ;
      _fx_free_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_33);
      _fx_free_Rt6Set__t1R9Ast__id_t(&tmp_idset_1);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&inst_env_2);
      if (df_inst_arg_0) {
         _fx_free_N10Ast__pat_t(&df_inst_arg_0);
      }
      _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_32);
      if (v_31) {
         _fx_free_N10Ast__pat_t(&v_31);
      }
      _fx_free_Rt6Set__t1R9Ast__id_t(&tmp_idset_0);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&inst_env_1);
      if (df_inst_args_2) {
         _fx_free_LN10Ast__pat_t(&df_inst_args_2);
      }
      _fx_free_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_30);
      FX_CHECK_EXN(_fx_cleanup);
   }
   int s_0 = !lst_0 + !lst_1;
   FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_cleanup);
   _fx_copy_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&__fold_result___0, &v_5);
   FX_COPY_PTR(v_5.t0, &df_inst_args_0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_5.t1, &inst_env_0);
   FX_CALL(_fx_M13Ast_typecheckFM3revLN10Ast__pat_t1LN10Ast__pat_t(df_inst_args_0, &df_inst_args_1, 0), _fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
         rt_0, &inst_env_0, df_scope_0, inst_loc_0, &rt_1, 0), _fx_cleanup);
   if (instantiate_0) {
      FX_CALL(_fx_M3AstFM7dup_expN10Ast__exp_t1N10Ast__exp_t(df_body_0, &inst_body_0, 0), _fx_cleanup);
   }
   else {
      FX_COPY_PTR(df_body_0, &inst_body_0);
   }
   FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(inst_body_0, &v_6, 0), _fx_cleanup);
   FX_COPY_PTR(v_6.t0, &body_typ_0);
   _fx_R10Ast__loc_t body_loc_0 = v_6.t1;
   if (!is_constr_0) {
      fx_str_t slit_7 = FX_MAKE_STR("the function body type does not match the function type");
      FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(body_typ_0, rt_1, &body_loc_0, &slit_7, 0),
         _fx_cleanup);
   }
   if (is_constr_0 == true) {
      if (arg_typs_1 == 0) {
         FX_COPY_PTR(rt_1, &inst_ftyp_2); goto _fx_endmatch_2;
      }
   }
   FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(arg_typs_1, rt_1, &inst_ftyp_2), _fx_catch_3);

_fx_catch_3: ;

_fx_endmatch_2: ;
   FX_CHECK_EXN(_fx_cleanup);
   _fx_R9Ast__id_t class_id_0 = df_flags_0.fun_flag_method_of;
   _fx_R16Ast__fun_flags_t v_34 =
      { df_flags_0.fun_flag_pure, df_flags_0.fun_flag_ccode, df_flags_0.fun_flag_have_keywords, df_flags_0.fun_flag_inline,
         df_flags_0.fun_flag_nothrow, df_flags_0.fun_flag_really_nothrow, df_flags_0.fun_flag_private, df_flags_0.fun_flag_ctor,
         class_id_0, df_flags_0.fun_flag_uses_fv, df_flags_0.fun_flag_recursive, instantiate_0 };
   FX_CALL(_fx_make_rLR9Ast__id_t(0, &v_7), _fx_cleanup);
   _fx_make_R13Ast__deffun_t(&inst_name_0, 0, df_inst_args_1, inst_ftyp_2, inst_body_0, &v_34, df_scope_0, inst_loc_0, v_7,
      inst_env0_0, &v_8);
   FX_CALL(_fx_make_rR13Ast__deffun_t(&v_8, &inst_df_0), _fx_cleanup);
   _fx_M3AstFM5IdFunN14Ast__id_info_t1rRM8deffun_t(inst_df_0, &v_9);
   FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&inst_name_0, &v_9, 0), _fx_cleanup);
   if (instantiate_0) {
      FX_COPY_PTR(templ_df_0->data.df_templ_inst, &v_10);
      FX_COPY_PTR(v_10->data, &v_11);
      FX_CALL(_fx_cons_LR9Ast__id_t(&inst_name_0, v_11, false, &v_11), _fx_cleanup);
      FX_COPY_PTR(templ_df_0->data.df_templ_inst, &v_12);
      _fx_LR9Ast__id_t* v_35 = &v_12->data;
      FX_FREE_LIST_SIMPLE(v_35);
      FX_COPY_PTR(v_11, v_35);
   }
   FX_COPY_PTR(_fx_g17Ast__all_func_ctx, &all_func_ctx_0);
   if (all_func_ctx_0 != 0) {
      fx_str_t slit_8 = FX_MAKE_STR("the function body has inconsistent type; check the type of return statements");
      FX_CALL(
         _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(all_func_ctx_0->hd.t1, rt_1, inst_loc_0,
            &slit_8, 0), _fx_catch_4);

   _fx_catch_4: ;
   }
   else {
      fx_exn_t v_36 = {0};
      fx_str_t slit_9 = FX_MAKE_STR("the function stack is empty for some reason");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &slit_9, &v_36, 0), _fx_catch_5);
      FX_THROW(&v_36, false, _fx_catch_5);

   _fx_catch_5: ;
      fx_free_exn(&v_36);
   }
   FX_CHECK_EXN(_fx_cleanup);
   FX_CALL(
      _fx_M13Ast_typecheckFM20instantiate_fun_bodyN10Ast__exp_t7R9Ast__id_tN10Ast__typ_tLN10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
         &inst_name_0, inst_ftyp_2, df_inst_args_1, inst_body_0, &inst_env_0, fun_sc_0, inst_loc_0, &inst_body_1, 0),
      _fx_cleanup);
   FX_CALL(_fx_M3AstFM11get_exp_typN10Ast__typ_t1N10Ast__exp_t(inst_body_1, &v_13, 0), _fx_cleanup);
   fx_str_t slit_10 =
      FX_MAKE_STR(
         "the function body has inconsistent type; check the type of return statements, all branches and the explicit return type specification, if any");
   FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(v_13, rt_1, inst_loc_0, &slit_10, 0),
      _fx_cleanup);
   if (is_constr_0 == true) {
      if (arg_typs_1 == 0) {
         FX_COPY_PTR(rt_1, &inst_ftyp_3); goto _fx_endmatch_3;
      }
   }
   FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(arg_typs_1, rt_1, &inst_ftyp_3), _fx_catch_6);

_fx_catch_6: ;

_fx_endmatch_3: ;
   FX_CHECK_EXN(_fx_cleanup);
   bool res_0;
   FX_CALL(_fx_M13Ast_typecheckFM6__ne__B2R9Ast__id_tR9Ast__id_t(&class_id_0, &_fx_g9Ast__noid, &res_0, 0), _fx_cleanup);
   bool t_0;
   if (res_0) {
      t_0 = !instantiate_0;
   }
   else {
      t_0 = false;
   }
   if (t_0) {
      if (df_scope_0 != 0) {
         if (df_scope_0->hd.tag == 10) {
            goto _fx_endmatch_4;
         }
      }
      fx_exn_t v_37 = {0};
      fx_str_t slit_11 = FX_MAKE_STR("a method may not be a local function");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &slit_11, &v_37, 0), _fx_catch_7);
      FX_THROW(&v_37, false, _fx_catch_7);

   _fx_catch_7: ;
      fx_free_exn(&v_37);

   _fx_endmatch_4: ;
      FX_CHECK_EXN(_fx_cleanup);
      _fx_LN10Ast__typ_t lstend_0 = 0;
      _fx_LN10Ast__typ_t lst_2 = arg_typs_1;
      for (; lst_2; lst_2 = lst_2->tl) {
         _fx_N10Ast__typ_t res_1 = 0;
         _fx_N10Ast__typ_t t_1 = lst_2->hd;
         FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t_1, &res_1, 0), _fx_catch_8);
         _fx_LN10Ast__typ_t node_0 = 0;
         FX_CALL(_fx_cons_LN10Ast__typ_t(res_1, 0, false, &node_0), _fx_catch_8);
         FX_LIST_APPEND(arg_typs_2, lstend_0, node_0);

      _fx_catch_8: ;
         if (res_1) {
            _fx_free_N10Ast__typ_t(&res_1);
         }
         FX_CHECK_EXN(_fx_cleanup);
      }
      if (arg_typs_2 != 0) {
         _fx_N10Ast__typ_t v_38 = arg_typs_2->hd;
         if (FX_REC_VARIANT_TAG(v_38) == 24) {
            _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_2 = &v_38->u.TypApp;
            if (vcase_2->t0 == 0) {
               _fx_N14Ast__id_info_t v_39 = {0};
               _fx_R9Ast__id_t* tn_0 = &vcase_2->t1;
               FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(tn_0, &df_loc_0, &v_39, 0), _fx_catch_11);
               if (v_39.tag == 6) {
                  _fx_rR17Ast__defvariant_t dvar_1 = v_39.u.IdVariant;
                  if (dvar_1->data.dvar_flags.var_flag_class_from > 0) {
                     _fx_N10Ast__typ_t v_40 = 0;
                     FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(arg_typs_2->tl, rt_1, &v_40),
                        _fx_catch_9);
                     _fx_make_T2rR17Ast__defvariant_tN10Ast__typ_t(dvar_1, v_40, &v_14);

                  _fx_catch_9: ;
                     if (v_40) {
                        _fx_free_N10Ast__typ_t(&v_40);
                     }
                     goto _fx_endmatch_5;
                  }
               }
               fx_str_t v_41 = {0};
               fx_str_t v_42 = {0};
               fx_str_t v_43 = {0};
               fx_exn_t v_44 = {0};
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(tn_0, &v_41, 0), _fx_catch_10);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_41, &v_42, 0), _fx_catch_10);
               fx_str_t slit_12 = FX_MAKE_STR("type \'");
               fx_str_t slit_13 = FX_MAKE_STR("\' is not a class");
               {
                  const fx_str_t strs_2[] = { slit_12, v_42, slit_13 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_2, 3, &v_43), _fx_catch_10);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &v_43, &v_44, 0), _fx_catch_10);
               FX_THROW(&v_44, false, _fx_catch_10);

            _fx_catch_10: ;
               fx_free_exn(&v_44);
               FX_FREE_STR(&v_43);
               FX_FREE_STR(&v_42);
               FX_FREE_STR(&v_41);

            _fx_endmatch_5: ;
               FX_CHECK_EXN(_fx_catch_11);

            _fx_catch_11: ;
               _fx_free_N14Ast__id_info_t(&v_39);
               goto _fx_endmatch_6;
            }
         }
      }
      if (arg_typs_2 != 0) {
         fx_str_t v_45 = {0};
         fx_str_t v_46 = {0};
         fx_str_t v_47 = {0};
         fx_exn_t v_48 = {0};
         FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(arg_typs_2->hd, &v_45, 0), _fx_catch_12);
         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_45, &v_46, 0), _fx_catch_12);
         fx_str_t slit_14 = FX_MAKE_STR("type \'");
         fx_str_t slit_15 = FX_MAKE_STR("\' is not an object");
         {
            const fx_str_t strs_3[] = { slit_14, v_46, slit_15 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_3, 3, &v_47), _fx_catch_12);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &v_47, &v_48, 0), _fx_catch_12);
         FX_THROW(&v_48, false, _fx_catch_12);

      _fx_catch_12: ;
         fx_free_exn(&v_48);
         FX_FREE_STR(&v_47);
         FX_FREE_STR(&v_46);
         FX_FREE_STR(&v_45);
         goto _fx_endmatch_6;
      }
      fx_exn_t v_49 = {0};
      fx_str_t slit_16 =
         FX_MAKE_STR(
            "internal error: non-empty arg list is expected, because self should have been added there automatically by the compiler");
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &slit_16, &v_49, 0), _fx_catch_13);
      FX_THROW(&v_49, false, _fx_catch_13);

   _fx_catch_13: ;
      fx_free_exn(&v_49);

   _fx_endmatch_6: ;
      FX_CHECK_EXN(_fx_cleanup);
      FX_COPY_PTR(v_14.t0, &dvar_0);
      FX_COPY_PTR(v_14.t1, &mtyp_0);
      _fx_R9Ast__id_t mname_0;
      FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&inst_name_0, &mname_0, 0), _fx_cleanup);
      _fx_R9Ast__id_t found_iface_0 = _fx_g9Ast__noid;
      FX_COPY_PTR(dvar_0->data.dvar_ifaces, &v_15);
      _fx_LT2R9Ast__id_tLTa2R9Ast__id_t lstend_1 = 0;
      _fx_LT2R9Ast__id_tLTa2R9Ast__id_t lst_3 = v_15;
      for (; lst_3; lst_3 = lst_3->tl) {
         _fx_LTa2R9Ast__id_t imethods_i_0 = 0;
         _fx_rR19Ast__definterface_t iface_0 = 0;
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_50 = 0;
         _fx_LTa2R9Ast__id_t imethods_i_1 = 0;
         _fx_T2R9Ast__id_tLTa2R9Ast__id_t tup_0 = {0};
         _fx_T2R9Ast__id_tLTa2R9Ast__id_t* __pat___0 = &lst_3->hd;
         _fx_R9Ast__id_t iname_i_0 = __pat___0->t0;
         FX_COPY_PTR(__pat___0->t1, &imethods_i_0);
         FX_CALL(_fx_M3AstFM9get_ifacerRM14definterface_t2RM4id_tRM5loc_t(&iname_i_0, &df_loc_0, &iface_0, 0), _fx_catch_15);
         FX_COPY_PTR(iface_0->data.di_all_methods, &v_50);
         _fx_LTa2R9Ast__id_t lstend_2 = 0;
         _fx_LTa2R9Ast__id_t lst_4 = imethods_i_0;
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t lst_5 = v_50;
         for (; lst_4 && lst_5; lst_5 = lst_5->tl, lst_4 = lst_4->tl) {
            _fx_N10Ast__typ_t tj_0 = 0;
            fx_str_t v_51 = {0};
            fx_str_t v_52 = {0};
            fx_str_t v_53 = {0};
            fx_str_t v_54 = {0};
            fx_str_t v_55 = {0};
            fx_exn_t v_56 = {0};
            fx_str_t v_57 = {0};
            fx_str_t v_58 = {0};
            fx_str_t v_59 = {0};
            fx_str_t v_60 = {0};
            fx_str_t v_61 = {0};
            fx_str_t v_62 = {0};
            fx_str_t v_63 = {0};
            fx_exn_t v_64 = {0};
            fx_str_t v_65 = {0};
            fx_str_t v_66 = {0};
            fx_str_t v_67 = {0};
            _fx_N14Ast__id_info_t v_68 = {0};
            fx_str_t v_69 = {0};
            fx_str_t v_70 = {0};
            fx_exn_t v_71 = {0};
            _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* __pat___1 = &lst_5->hd;
            _fx_Ta2R9Ast__id_t* __pat___2 = &lst_4->hd;
            _fx_R9Ast__id_t m_j_0 = __pat___2->t0;
            _fx_R9Ast__id_t impl_j_0 = __pat___2->t1;
            _fx_R9Ast__id_t m1_j_0 = __pat___1->t0;
            FX_COPY_PTR(__pat___1->t1, &tj_0);
            bool res_2;
            FX_CALL(_fx_M13Ast_typecheckFM6__ne__B2R9Ast__id_tR9Ast__id_t(&m_j_0, &m1_j_0, &res_2, 0), _fx_catch_14);
            if (res_2) {
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&m_j_0, &v_51, 0), _fx_catch_14);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_51, &v_52, 0), _fx_catch_14);
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&m1_j_0, &v_53, 0), _fx_catch_14);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_53, &v_54, 0), _fx_catch_14);
               fx_str_t slit_17 = FX_MAKE_STR("internal err: method ");
               fx_str_t slit_18 = FX_MAKE_STR(" does not match method ");
               {
                  const fx_str_t strs_4[] = { slit_17, v_52, slit_18, v_54 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_4, 4, &v_55), _fx_catch_14);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &v_55, &v_56, 0), _fx_catch_14);
               FX_THROW(&v_56, false, _fx_catch_14);
            }
            _fx_R9Ast__id_t v_72;
            FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&m_j_0, &v_72, 0), _fx_catch_14);
            bool v_73;
            bool res_3;
            FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&mname_0, &v_72, &res_3, 0), _fx_catch_14);
            if (res_3) {
               FX_CALL(
                  _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(mtyp_0, tj_0, inst_loc_0, false,
                     &v_73, 0), _fx_catch_14);
            }
            else {
               v_73 = false;
            }
            _fx_Ta2R9Ast__id_t t_2;
            if (v_73) {
               bool res_4;
               FX_CALL(_fx_M13Ast_typecheckFM6__ne__B2R9Ast__id_tR9Ast__id_t(&found_iface_0, &_fx_g9Ast__noid, &res_4, 0),
                  _fx_catch_14);
               if (res_4) {
                  FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&iname_i_0, &v_57, 0), _fx_catch_14);
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_57, &v_58, 0), _fx_catch_14);
                  FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&mname_0, &v_59, 0), _fx_catch_14);
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_59, &v_60, 0), _fx_catch_14);
                  FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&found_iface_0, &v_61, 0), _fx_catch_14);
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_61, &v_62, 0), _fx_catch_14);
                  fx_str_t slit_19 = FX_MAKE_STR("method \'");
                  fx_str_t slit_20 = FX_MAKE_STR(".");
                  fx_str_t slit_21 = FX_MAKE_STR("\' with the same signature is also defined in \'");
                  fx_str_t slit_22 = FX_MAKE_STR("\'. Consider renaming one of them");
                  {
                     const fx_str_t strs_5[] = { slit_19, v_58, slit_20, v_60, slit_21, v_62, slit_22 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_5, 7, &v_63), _fx_catch_14);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&df_loc_0, &v_63, &v_64, 0), _fx_catch_14);
                  FX_THROW(&v_64, false, _fx_catch_14);
               }
               bool res_5;
               FX_CALL(_fx_M13Ast_typecheckFM6__ne__B2R9Ast__id_tR9Ast__id_t(&impl_j_0, &_fx_g9Ast__noid, &res_5, 0),
                  _fx_catch_14);
               if (res_5) {
                  FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&iname_i_0, &v_65, 0), _fx_catch_14);
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_65, &v_66, 0), _fx_catch_14);
                  FX_CALL(_fx_M3AstFM6stringS1RM4id_t(&mname_0, &v_67, 0), _fx_catch_14);
                  FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&impl_j_0, inst_loc_0, &v_68, 0), _fx_catch_14);
                  _fx_R10Ast__loc_t v_74;
                  FX_CALL(_fx_M3AstFM14get_idinfo_locRM5loc_t1N14Ast__id_info_t(&v_68, &v_74, 0), _fx_catch_14);
                  FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(&v_74, &v_69, 0), _fx_catch_14);
                  fx_str_t slit_23 = FX_MAKE_STR("method \'");
                  fx_str_t slit_24 = FX_MAKE_STR(".");
                  fx_str_t slit_25 = FX_MAKE_STR("\' is already defined at ");
                  {
                     const fx_str_t strs_6[] = { slit_23, v_66, slit_24, v_67, slit_25, v_69 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_6, 6, &v_70), _fx_catch_14);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &v_70, &v_71, 0), _fx_catch_14);
                  FX_THROW(&v_71, false, _fx_catch_14);
               }
               found_iface_0 = iname_i_0;
               _fx_Ta2R9Ast__id_t tup_1 = { m_j_0, inst_name_0 };
               t_2 = tup_1;
            }
            else {
               _fx_Ta2R9Ast__id_t tup_2 = { m_j_0, impl_j_0 }; t_2 = tup_2;
            }
            _fx_LTa2R9Ast__id_t node_1 = 0;
            FX_CALL(_fx_cons_LTa2R9Ast__id_t(&t_2, 0, false, &node_1), _fx_catch_14);
            FX_LIST_APPEND(imethods_i_1, lstend_2, node_1);

         _fx_catch_14: ;
            fx_free_exn(&v_71);
            FX_FREE_STR(&v_70);
            FX_FREE_STR(&v_69);
            _fx_free_N14Ast__id_info_t(&v_68);
            FX_FREE_STR(&v_67);
            FX_FREE_STR(&v_66);
            FX_FREE_STR(&v_65);
            fx_free_exn(&v_64);
            FX_FREE_STR(&v_63);
            FX_FREE_STR(&v_62);
            FX_FREE_STR(&v_61);
            FX_FREE_STR(&v_60);
            FX_FREE_STR(&v_59);
            FX_FREE_STR(&v_58);
            FX_FREE_STR(&v_57);
            fx_free_exn(&v_56);
            FX_FREE_STR(&v_55);
            FX_FREE_STR(&v_54);
            FX_FREE_STR(&v_53);
            FX_FREE_STR(&v_52);
            FX_FREE_STR(&v_51);
            if (tj_0) {
               _fx_free_N10Ast__typ_t(&tj_0);
            }
            FX_CHECK_EXN(_fx_catch_15);
         }
         int s_1 = !lst_4 + !lst_5;
         FX_CHECK_EQ_SIZE(s_1 == 0 || s_1 == 2, _fx_catch_15);
         _fx_make_T2R9Ast__id_tLTa2R9Ast__id_t(&iname_i_0, imethods_i_1, &tup_0);
         _fx_LT2R9Ast__id_tLTa2R9Ast__id_t node_2 = 0;
         FX_CALL(_fx_cons_LT2R9Ast__id_tLTa2R9Ast__id_t(&tup_0, 0, false, &node_2), _fx_catch_15);
         FX_LIST_APPEND(dvar_ifaces_0, lstend_1, node_2);

      _fx_catch_15: ;
         _fx_free_T2R9Ast__id_tLTa2R9Ast__id_t(&tup_0);
         FX_FREE_LIST_SIMPLE(&imethods_i_1);
         if (v_50) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_50);
         }
         if (iface_0) {
            _fx_free_rR19Ast__definterface_t(&iface_0);
         }
         FX_FREE_LIST_SIMPLE(&imethods_i_0);
         FX_CHECK_EXN(_fx_cleanup);
      }
      bool res_6;
      FX_CALL(_fx_M13Ast_typecheckFM6__ne__B2R9Ast__id_tR9Ast__id_t(&found_iface_0, &_fx_g9Ast__noid, &res_6, 0), _fx_cleanup);
      if (res_6) {
         _fx_R17Ast__defvariant_t* v_75 = &dvar_0->data;
         _fx_make_R17Ast__defvariant_t(&v_75->dvar_name, v_75->dvar_templ_args, v_75->dvar_alias, &v_75->dvar_flags,
            v_75->dvar_cases, v_75->dvar_ctors, v_75->dvar_templ_inst, dvar_ifaces_0, v_75->dvar_scope, &v_75->dvar_loc, &v_16);
         _fx_R17Ast__defvariant_t* v_76 = &dvar_0->data;
         _fx_free_R17Ast__defvariant_t(v_76);
         _fx_copy_R17Ast__defvariant_t(&v_16, v_76);
      }
   }
   _fx_R13Ast__deffun_t* v_77 = &inst_df_0->data;
   _fx_make_R13Ast__deffun_t(&v_77->df_name, v_77->df_templ_args, v_77->df_args, inst_ftyp_3, inst_body_1, &v_77->df_flags,
      v_77->df_scope, &v_77->df_loc, v_77->df_templ_inst, &v_77->df_env, &v_17);
   _fx_R13Ast__deffun_t* v_78 = &inst_df_0->data;
   _fx_free_R13Ast__deffun_t(v_78);
   _fx_copy_R13Ast__deffun_t(&v_17, v_78);
   FX_COPY_PTR(inst_df_0, fx_result);

_fx_cleanup: ;
   FX_FREE_LIST_SIMPLE(&df_scope_0);
   if (df_body_0) {
      _fx_free_N10Ast__exp_t(&df_body_0);
   }
   if (df_args_0) {
      _fx_free_LN10Ast__pat_t(&df_args_0);
   }
   FX_FREE_STR(&v_0);
   FX_FREE_STR(&v_1);
   fx_free_exn(&v_2);
   if (inst_ftyp_1) {
      _fx_free_N10Ast__typ_t(&inst_ftyp_1);
   }
   _fx_free_T2LN10Ast__typ_tN10Ast__typ_t(&v_3);
   if (arg_typs_0) {
      _fx_free_LN10Ast__typ_t(&arg_typs_0);
   }
   if (rt_0) {
      _fx_free_N10Ast__typ_t(&rt_0);
   }
   if (arg_typs_1) {
      _fx_free_LN10Ast__typ_t(&arg_typs_1);
   }
   if (v_4) {
      _fx_free_N10Ast__typ_t(&v_4);
   }
   FX_FREE_LIST_SIMPLE(&fun_sc_0);
   _fx_free_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&__fold_result___0);
   _fx_free_T3LN10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_t(&v_5);
   if (df_inst_args_0) {
      _fx_free_LN10Ast__pat_t(&df_inst_args_0);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&inst_env_0);
   if (df_inst_args_1) {
      _fx_free_LN10Ast__pat_t(&df_inst_args_1);
   }
   if (rt_1) {
      _fx_free_N10Ast__typ_t(&rt_1);
   }
   if (inst_body_0) {
      _fx_free_N10Ast__exp_t(&inst_body_0);
   }
   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_6);
   if (body_typ_0) {
      _fx_free_N10Ast__typ_t(&body_typ_0);
   }
   if (inst_ftyp_2) {
      _fx_free_N10Ast__typ_t(&inst_ftyp_2);
   }
   if (v_7) {
      _fx_free_rLR9Ast__id_t(&v_7);
   }
   _fx_free_R13Ast__deffun_t(&v_8);
   if (inst_df_0) {
      _fx_free_rR13Ast__deffun_t(&inst_df_0);
   }
   _fx_free_N14Ast__id_info_t(&v_9);
   if (v_10) {
      _fx_free_rLR9Ast__id_t(&v_10);
   }
   FX_FREE_LIST_SIMPLE(&v_11);
   if (v_12) {
      _fx_free_rLR9Ast__id_t(&v_12);
   }
   if (all_func_ctx_0) {
      _fx_free_LT3R9Ast__id_tN10Ast__typ_tR10Ast__loc_t(&all_func_ctx_0);
   }
   if (inst_body_1) {
      _fx_free_N10Ast__exp_t(&inst_body_1);
   }
   if (v_13) {
      _fx_free_N10Ast__typ_t(&v_13);
   }
   if (inst_ftyp_3) {
      _fx_free_N10Ast__typ_t(&inst_ftyp_3);
   }
   if (arg_typs_2) {
      _fx_free_LN10Ast__typ_t(&arg_typs_2);
   }
   _fx_free_T2rR17Ast__defvariant_tN10Ast__typ_t(&v_14);
   if (dvar_0) {
      _fx_free_rR17Ast__defvariant_t(&dvar_0);
   }
   if (mtyp_0) {
      _fx_free_N10Ast__typ_t(&mtyp_0);
   }
   if (v_15) {
      _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(&v_15);
   }
   if (dvar_ifaces_0) {
      _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(&dvar_ifaces_0);
   }
   _fx_free_R17Ast__defvariant_t(&v_16);
   _fx_free_R13Ast__deffun_t(&v_17);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM20instantiate_fun_bodyN10Ast__exp_t7R9Ast__id_tN10Ast__typ_tLN10Ast__pat_tN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* inst_name_0,
   struct _fx_N10Ast__typ_t_data_t* inst_ftyp_0,
   struct _fx_LN10Ast__pat_t_data_t* inst_args_0,
   struct _fx_N10Ast__exp_t_data_t* inst_body_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* inst_env_0,
   struct _fx_LN12Ast__scope_t_data_t* fun_sc_0,
   struct _fx_R10Ast__loc_t* inst_loc_0,
   struct _fx_N10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t ftyp_0 = 0;
   fx_str_t v_0 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   FX_CALL(_fx_M3AstFM13deref_typ_recN10Ast__typ_t1N10Ast__typ_t(inst_ftyp_0, &ftyp_0, 0), _fx_cleanup);
   _fx_R10Ast__loc_t body_loc_0;
   FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(inst_body_0, &body_loc_0, 0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM2ppS1RM4id_t(inst_name_0, &v_0, 0), _fx_cleanup);
   fx_str_t slit_0 = FX_MAKE_STR("__eq_variants__");
   if (fx_streq(&v_0, &slit_0)) {
      _fx_N14Ast__id_info_t v_1 = {0};
      if (inst_args_0 != 0) {
         _fx_LN10Ast__pat_t v_2 = inst_args_0->tl;
         if (v_2 != 0) {
            if (v_2->tl == 0) {
               _fx_N10Ast__pat_t v_3 = v_2->hd;
               if (FX_REC_VARIANT_TAG(v_3) == 9) {
                  _fx_N10Ast__pat_t v_4 = v_3->u.PatTyped.t0;
                  if (FX_REC_VARIANT_TAG(v_4) == 3) {
                     _fx_N10Ast__pat_t v_5 = inst_args_0->hd;
                     if (FX_REC_VARIANT_TAG(v_5) == 9) {
                        _fx_N10Ast__pat_t v_6 = v_5->u.PatTyped.t0;
                        if (FX_REC_VARIANT_TAG(v_6) == 3) {
                           if (FX_REC_VARIANT_TAG(ftyp_0) == 14) {
                              _fx_T2LN10Ast__typ_tN10Ast__typ_t* vcase_0 = &ftyp_0->u.TypFun;
                              _fx_LN10Ast__typ_t v_7 = vcase_0->t0;
                              if (v_7 != 0) {
                                 _fx_LN10Ast__typ_t v_8 = v_7->tl;
                                 if (v_8 != 0) {
                                    if (v_8->tl == 0) {
                                       _fx_N10Ast__typ_t t2_0 = v_8->hd;
                                       if (FX_REC_VARIANT_TAG(t2_0) == 24) {
                                          _fx_N10Ast__typ_t t1_0 = v_7->hd;
                                          if (FX_REC_VARIANT_TAG(t1_0) == 24) {
                                             _fx_R9Ast__id_t* n1_0 = &t1_0->u.TypApp.t1;
                                             bool res_0;
                                             FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(n1_0, &t2_0->u.TypApp.t1, &res_0, 0),
                                                _fx_catch_12);
                                             bool t_0;
                                             if (res_0) {
                                                FX_CALL(
                                                   _fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(n1_0, inst_loc_0, &v_1,
                                                      0), _fx_catch_12);
                                                if (v_1.tag == 6) {
                                                   t_0 = true;
                                                }
                                                else {
                                                   t_0 = false;
                                                }
                                                FX_CHECK_EXN(_fx_catch_12);
                                             }
                                             else {
                                                t_0 = false;
                                             }
                                             if (t_0) {
                                                fx_str_t astr_0 = {0};
                                                fx_str_t bstr_0 = {0};
                                                _fx_N14Ast__id_info_t v_9 = {0};
                                                _fx_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t v_10 = {0};
                                                _fx_R17Ast__defvariant_t v_11 = {0};
                                                _fx_LR9Ast__id_t var_ctors_0 = 0;
                                                _fx_LT2R9Ast__id_tN10Ast__typ_t proto_cases_0 = 0;
                                                _fx_LT2N10Ast__pat_tN10Ast__exp_t __fold_result___0 = 0;
                                                _fx_LT2N10Ast__pat_tN10Ast__exp_t complex_cases_0 = 0;
                                                _fx_T2N10Ast__typ_tR10Ast__loc_t v_12 = {0};
                                                _fx_N10Ast__exp_t a_0 = 0;
                                                _fx_T2N10Ast__typ_tR10Ast__loc_t v_13 = {0};
                                                _fx_N10Ast__exp_t b_0 = 0;
                                                _fx_T2N10Ast__typ_tR10Ast__loc_t v_14 = {0};
                                                _fx_N10Ast__exp_t tag_0 = 0;
                                                _fx_T2N10Ast__typ_tR10Ast__loc_t v_15 = {0};
                                                _fx_N10Ast__exp_t a_tag_0 = 0;
                                                _fx_T2N10Ast__typ_tR10Ast__loc_t v_16 = {0};
                                                _fx_N10Ast__exp_t b_tag_0 = 0;
                                                _fx_N13Ast__binary_t v_17 = 0;
                                                _fx_T2N10Ast__typ_tR10Ast__loc_t v_18 = {0};
                                                _fx_N10Ast__exp_t cmp_tags_0 = 0;
                                                _fx_N10Ast__exp_t inst_body_1 = 0;
                                                fx_str_t slit_1 =
                                                   FX_MAKE_STR(
                                                      "arguments of variant comparison operation should have the same type");
                                                FX_CALL(
                                                   _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t1_0,
                                                      t2_0, inst_loc_0, &slit_1, 0), _fx_catch_10);
                                                fx_str_t slit_2 =
                                                   FX_MAKE_STR("variant comparison operation should produce \'bool\'");
                                                FX_CALL(
                                                   _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(
                                                      vcase_0->t1, _fx_g22Ast_typecheck__TypBool, inst_loc_0, &slit_2, 0),
                                                   _fx_catch_10);
                                                FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_6->u.PatIdent.t0, &astr_0, 0), _fx_catch_10);
                                                FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_4->u.PatIdent.t0, &bstr_0, 0), _fx_catch_10);
                                                FX_CALL(
                                                   _fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(n1_0, inst_loc_0, &v_9,
                                                      0), _fx_catch_10);
                                                if (v_9.tag == 6) {
                                                   _fx_copy_R17Ast__defvariant_t(&v_9.u.IdVariant->data, &v_11);
                                                   _fx_N10Ast__typ_t v_19 = v_11.dvar_alias;
                                                   if (FX_REC_VARIANT_TAG(v_19) == 24) {
                                                      _fx_N14Ast__id_info_t v_20 = {0};
                                                      FX_CALL(
                                                         _fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(
                                                            &v_19->u.TypApp.t1, &v_11.dvar_loc, &v_20, 0), _fx_catch_1);
                                                      if (v_20.tag == 6) {
                                                         _fx_R17Ast__defvariant_t v_21 = {0};
                                                         _fx_copy_R17Ast__defvariant_t(&v_20.u.IdVariant->data, &v_21);
                                                         _fx_make_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t(v_11.dvar_ctors,
                                                            v_21.dvar_cases, &v_10);
                                                         _fx_free_R17Ast__defvariant_t(&v_21);
                                                      }
                                                      else {
                                                         fx_exn_t v_22 = {0};
                                                         fx_str_t slit_3 =
                                                            FX_MAKE_STR(
                                                               "the prototype of variant instance should be a variant");
                                                         FX_CALL(
                                                            _fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &slit_3, &v_22, 0),
                                                            _fx_catch_0);
                                                         FX_THROW(&v_22, false, _fx_catch_0);

                                                      _fx_catch_0: ;
                                                         fx_free_exn(&v_22);
                                                      }
                                                      FX_CHECK_EXN(_fx_catch_1);

                                                   _fx_catch_1: ;
                                                      _fx_free_N14Ast__id_info_t(&v_20);
                                                      goto _fx_endmatch_0;
                                                   }
                                                }
                                                fx_exn_t v_23 = {0};
                                                fx_str_t slit_4 = FX_MAKE_STR("variant is expected here");
                                                FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &slit_4, &v_23, 0),
                                                   _fx_catch_2);
                                                FX_THROW(&v_23, false, _fx_catch_2);

                                             _fx_catch_2: ;
                                                fx_free_exn(&v_23);

                                             _fx_endmatch_0: ;
                                                FX_CHECK_EXN(_fx_catch_10);
                                                FX_COPY_PTR(v_10.t0, &var_ctors_0);
                                                FX_COPY_PTR(v_10.t1, &proto_cases_0);
                                                _fx_LR9Ast__id_t lst_0 = var_ctors_0;
                                                _fx_LT2R9Ast__id_tN10Ast__typ_t lst_1 = proto_cases_0;
                                                for (; lst_0 && lst_1; lst_1 = lst_1->tl, lst_0 = lst_0->tl) {
                                                   _fx_N10Ast__typ_t t_orig_0 = 0;
                                                   _fx_LT2N10Ast__pat_tN10Ast__exp_t complex_cases_1 = 0;
                                                   _fx_N10Ast__typ_t t_1 = 0;
                                                   _fx_LT2N10Ast__pat_tN10Ast__exp_t v_24 = 0;
                                                   _fx_T2R9Ast__id_tN10Ast__typ_t* __pat___0 = &lst_1->hd;
                                                   _fx_R9Ast__id_t* n_0 = &lst_0->hd;
                                                   FX_COPY_PTR(__pat___0->t1, &t_orig_0);
                                                   FX_COPY_PTR(__fold_result___0, &complex_cases_1);
                                                   FX_CALL(
                                                      _fx_M3AstFM13deref_typ_recN10Ast__typ_t1N10Ast__typ_t(t_orig_0, &t_1, 0),
                                                      _fx_catch_8);
                                                   int tag_1 = FX_REC_VARIANT_TAG(t_1);
                                                   if (tag_1 == 13) {
                                                      FX_COPY_PTR(complex_cases_1, &v_24);
                                                   }
                                                   else if (tag_1 == 20) {
                                                      _fx_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB v_25 =
                                                         {0};
                                                      _fx_N10Ast__exp_t v_26 = 0;
                                                      _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t
                                                         __fold_result___1 = {0};
                                                      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_0 =
                                                         0;
                                                      _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t
                                                         v_27 = {0};
                                                      _fx_LT2R9Ast__id_tN10Ast__pat_t al_0 = 0;
                                                      _fx_LT2R9Ast__id_tN10Ast__pat_t bl_0 = 0;
                                                      _fx_N10Ast__exp_t cmp_code_0 = 0;
                                                      _fx_LT2R9Ast__id_tN10Ast__pat_t v_28 = 0;
                                                      _fx_N10Ast__pat_t a_case_pat_0 = 0;
                                                      _fx_LT2R9Ast__id_tN10Ast__pat_t v_29 = 0;
                                                      _fx_N10Ast__pat_t b_case_pat_0 = 0;
                                                      _fx_LN10Ast__pat_t v_30 = 0;
                                                      _fx_N10Ast__pat_t ab_case_pat_0 = 0;
                                                      _fx_T2N10Ast__pat_tN10Ast__exp_t v_31 = {0};
                                                      _fx_copy_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
                                                         &t_1->u.TypRecord->data, &v_25);
                                                      FX_CALL(_fx_M3AstFM6ExpNopN10Ast__exp_t1RM5loc_t(&body_loc_0, &v_26),
                                                         _fx_catch_4);
                                                      _fx_make_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                         0, 0, v_26, &__fold_result___1);
                                                      int_ idx_0 = 0;
                                                      FX_COPY_PTR(v_25.t0, &relems_0);
                                                      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_2 =
                                                         relems_0;
                                                      for (; lst_2; lst_2 = lst_2->tl, idx_0 += 1) {
                                                         _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t
                                                            v_32 = {0};
                                                         _fx_LT2R9Ast__id_tN10Ast__pat_t al_1 = 0;
                                                         _fx_LT2R9Ast__id_tN10Ast__pat_t bl_1 = 0;
                                                         _fx_N10Ast__exp_t cmp_code_1 = 0;
                                                         fx_str_t v_33 = {0};
                                                         fx_str_t v_34 = {0};
                                                         fx_str_t v_35 = {0};
                                                         fx_str_t v_36 = {0};
                                                         fx_str_t v_37 = {0};
                                                         fx_str_t v_38 = {0};
                                                         _fx_N13Ast__binary_t v_39 = 0;
                                                         _fx_N10Ast__typ_t v_40 = 0;
                                                         _fx_T2N10Ast__typ_tR10Ast__loc_t v_41 = {0};
                                                         _fx_N10Ast__exp_t v_42 = 0;
                                                         _fx_N10Ast__typ_t v_43 = 0;
                                                         _fx_T2N10Ast__typ_tR10Ast__loc_t v_44 = {0};
                                                         _fx_N10Ast__exp_t v_45 = 0;
                                                         _fx_T2N10Ast__typ_tR10Ast__loc_t v_46 = {0};
                                                         _fx_N10Ast__exp_t cmp_ab_0 = 0;
                                                         _fx_N10Ast__exp_t cmp_code_2 = 0;
                                                         _fx_T2N10Ast__typ_tR10Ast__loc_t v_47 = {0};
                                                         _fx_N10Ast__pat_t v_48 = 0;
                                                         _fx_T2R9Ast__id_tN10Ast__pat_t v_49 = {0};
                                                         _fx_N10Ast__pat_t v_50 = 0;
                                                         _fx_T2R9Ast__id_tN10Ast__pat_t v_51 = {0};
                                                         _fx_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t
                                                            v_52 = {0};
                                                         _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t*
                                                            __pat___1 = &lst_2->hd;
                                                         _fx_R9Ast__id_t rn_0 = __pat___1->t1;
                                                         _fx_copy_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                            &__fold_result___1, &v_32);
                                                         FX_COPY_PTR(v_32.t0, &al_1);
                                                         FX_COPY_PTR(v_32.t1, &bl_1);
                                                         FX_COPY_PTR(v_32.t2, &cmp_code_1);
                                                         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&astr_0, &v_33, 0),
                                                            _fx_catch_3);
                                                         FX_CALL(_fx_F6stringS1i(idx_0, &v_34, 0), _fx_catch_3);
                                                         {
                                                            const fx_str_t strs_0[] = { v_33, v_34 };
                                                            FX_CALL(fx_strjoin(0, 0, 0, strs_0, 2, &v_35), _fx_catch_3);
                                                         }
                                                         _fx_R9Ast__id_t ai_0;
                                                         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_35, &ai_0, 0), _fx_catch_3);
                                                         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&bstr_0, &v_36, 0),
                                                            _fx_catch_3);
                                                         FX_CALL(_fx_F6stringS1i(idx_0, &v_37, 0), _fx_catch_3);
                                                         {
                                                            const fx_str_t strs_1[] = { v_36, v_37 };
                                                            FX_CALL(fx_strjoin(0, 0, 0, strs_1, 2, &v_38), _fx_catch_3);
                                                         }
                                                         _fx_R9Ast__id_t bi_0;
                                                         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_38, &bi_0, 0), _fx_catch_3);
                                                         FX_CALL(
                                                            _fx_M3AstFM5OpCmpN13Ast__binary_t1N12Ast__cmpop_t(
                                                               &_fx_g20Ast_typecheck__CmpEQ, &v_39), _fx_catch_3);
                                                         FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_40, 0),
                                                            _fx_catch_3);
                                                         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_40, &body_loc_0, &v_41);
                                                         FX_CALL(
                                                            _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(
                                                               &ai_0, &v_41, &v_42), _fx_catch_3);
                                                         FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_43, 0),
                                                            _fx_catch_3);
                                                         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_43, &body_loc_0, &v_44);
                                                         FX_CALL(
                                                            _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(
                                                               &bi_0, &v_44, &v_45), _fx_catch_3);
                                                         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g22Ast_typecheck__TypBool,
                                                            &body_loc_0, &v_46);
                                                         FX_CALL(
                                                            _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                               v_39, v_42, v_45, &v_46, &cmp_ab_0), _fx_catch_3);
                                                         if (idx_0 == 0) {
                                                            FX_COPY_PTR(cmp_ab_0, &cmp_code_2);
                                                         }
                                                         else {
                                                            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g22Ast_typecheck__TypBool,
                                                               &body_loc_0, &v_47);
                                                            FX_CALL(
                                                               _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                                  _fx_g27Ast_typecheck__OpBitwiseAnd, cmp_code_1, cmp_ab_0,
                                                                  &v_47, &cmp_code_2), _fx_catch_3);
                                                         }
                                                         FX_CALL(
                                                            _fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&ai_0,
                                                               &body_loc_0, &v_48), _fx_catch_3);
                                                         _fx_make_T2R9Ast__id_tN10Ast__pat_t(&rn_0, v_48, &v_49);
                                                         FX_CALL(
                                                            _fx_cons_LT2R9Ast__id_tN10Ast__pat_t(&v_49, al_1, false, &al_1),
                                                            _fx_catch_3);
                                                         FX_CALL(
                                                            _fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&bi_0,
                                                               &body_loc_0, &v_50), _fx_catch_3);
                                                         _fx_make_T2R9Ast__id_tN10Ast__pat_t(&rn_0, v_50, &v_51);
                                                         FX_CALL(
                                                            _fx_cons_LT2R9Ast__id_tN10Ast__pat_t(&v_51, bl_1, false, &bl_1),
                                                            _fx_catch_3);
                                                         _fx_make_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                            al_1, bl_1, cmp_code_2, &v_52);
                                                         _fx_free_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                            &__fold_result___1);
                                                         _fx_copy_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                            &v_52, &__fold_result___1);

                                                      _fx_catch_3: ;
                                                         _fx_free_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                            &v_52);
                                                         _fx_free_T2R9Ast__id_tN10Ast__pat_t(&v_51);
                                                         if (v_50) {
                                                            _fx_free_N10Ast__pat_t(&v_50);
                                                         }
                                                         _fx_free_T2R9Ast__id_tN10Ast__pat_t(&v_49);
                                                         if (v_48) {
                                                            _fx_free_N10Ast__pat_t(&v_48);
                                                         }
                                                         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_47);
                                                         if (cmp_code_2) {
                                                            _fx_free_N10Ast__exp_t(&cmp_code_2);
                                                         }
                                                         if (cmp_ab_0) {
                                                            _fx_free_N10Ast__exp_t(&cmp_ab_0);
                                                         }
                                                         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_46);
                                                         if (v_45) {
                                                            _fx_free_N10Ast__exp_t(&v_45);
                                                         }
                                                         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_44);
                                                         if (v_43) {
                                                            _fx_free_N10Ast__typ_t(&v_43);
                                                         }
                                                         if (v_42) {
                                                            _fx_free_N10Ast__exp_t(&v_42);
                                                         }
                                                         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_41);
                                                         if (v_40) {
                                                            _fx_free_N10Ast__typ_t(&v_40);
                                                         }
                                                         if (v_39) {
                                                            _fx_free_N13Ast__binary_t(&v_39);
                                                         }
                                                         FX_FREE_STR(&v_38);
                                                         FX_FREE_STR(&v_37);
                                                         FX_FREE_STR(&v_36);
                                                         FX_FREE_STR(&v_35);
                                                         FX_FREE_STR(&v_34);
                                                         FX_FREE_STR(&v_33);
                                                         if (cmp_code_1) {
                                                            _fx_free_N10Ast__exp_t(&cmp_code_1);
                                                         }
                                                         if (bl_1) {
                                                            _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&bl_1);
                                                         }
                                                         if (al_1) {
                                                            _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&al_1);
                                                         }
                                                         _fx_free_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                            &v_32);
                                                         FX_CHECK_EXN(_fx_catch_4);
                                                      }
                                                      _fx_copy_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                         &__fold_result___1, &v_27);
                                                      FX_COPY_PTR(v_27.t0, &al_0);
                                                      FX_COPY_PTR(v_27.t1, &bl_0);
                                                      FX_COPY_PTR(v_27.t2, &cmp_code_0);
                                                      _fx_Nt6option1R9Ast__id_t v_53;
                                                      _fx_M13Ast_typecheckFM4SomeNt6option1R9Ast__id_t1R9Ast__id_t(n_0, &v_53);
                                                      FX_CALL(
                                                         _fx_M13Ast_typecheckFM3revLT2R9Ast__id_tN10Ast__pat_t1LT2R9Ast__id_tN10Ast__pat_t(
                                                            al_0, &v_28, 0), _fx_catch_4);
                                                      FX_CALL(
                                                         _fx_M3AstFM9PatRecordN10Ast__pat_t3Nt6option1RM4id_tLT2RM4id_tN10Ast__pat_tRM5loc_t(
                                                            &v_53, v_28, &body_loc_0, &a_case_pat_0), _fx_catch_4);
                                                      _fx_Nt6option1R9Ast__id_t v_54;
                                                      _fx_M13Ast_typecheckFM4SomeNt6option1R9Ast__id_t1R9Ast__id_t(n_0, &v_54);
                                                      FX_CALL(
                                                         _fx_M13Ast_typecheckFM3revLT2R9Ast__id_tN10Ast__pat_t1LT2R9Ast__id_tN10Ast__pat_t(
                                                            bl_0, &v_29, 0), _fx_catch_4);
                                                      FX_CALL(
                                                         _fx_M3AstFM9PatRecordN10Ast__pat_t3Nt6option1RM4id_tLT2RM4id_tN10Ast__pat_tRM5loc_t(
                                                            &v_54, v_29, &body_loc_0, &b_case_pat_0), _fx_catch_4);
                                                      FX_CALL(_fx_cons_LN10Ast__pat_t(b_case_pat_0, 0, true, &v_30),
                                                         _fx_catch_4);
                                                      FX_CALL(_fx_cons_LN10Ast__pat_t(a_case_pat_0, v_30, false, &v_30),
                                                         _fx_catch_4);
                                                      FX_CALL(
                                                         _fx_M3AstFM8PatTupleN10Ast__pat_t2LN10Ast__pat_tRM5loc_t(v_30,
                                                            &body_loc_0, &ab_case_pat_0), _fx_catch_4);
                                                      _fx_make_T2N10Ast__pat_tN10Ast__exp_t(ab_case_pat_0, cmp_code_0, &v_31);
                                                      FX_CALL(
                                                         _fx_cons_LT2N10Ast__pat_tN10Ast__exp_t(&v_31, complex_cases_1, true,
                                                            &v_24), _fx_catch_4);

                                                   _fx_catch_4: ;
                                                      _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&v_31);
                                                      if (ab_case_pat_0) {
                                                         _fx_free_N10Ast__pat_t(&ab_case_pat_0);
                                                      }
                                                      if (v_30) {
                                                         _fx_free_LN10Ast__pat_t(&v_30);
                                                      }
                                                      if (b_case_pat_0) {
                                                         _fx_free_N10Ast__pat_t(&b_case_pat_0);
                                                      }
                                                      if (v_29) {
                                                         _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&v_29);
                                                      }
                                                      if (a_case_pat_0) {
                                                         _fx_free_N10Ast__pat_t(&a_case_pat_0);
                                                      }
                                                      if (v_28) {
                                                         _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&v_28);
                                                      }
                                                      if (cmp_code_0) {
                                                         _fx_free_N10Ast__exp_t(&cmp_code_0);
                                                      }
                                                      if (bl_0) {
                                                         _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&bl_0);
                                                      }
                                                      if (al_0) {
                                                         _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&al_0);
                                                      }
                                                      _fx_free_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                         &v_27);
                                                      if (relems_0) {
                                                         _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
                                                            &relems_0);
                                                      }
                                                      _fx_free_T3LT2R9Ast__id_tN10Ast__pat_tLT2R9Ast__id_tN10Ast__pat_tN10Ast__exp_t(
                                                         &__fold_result___1);
                                                      if (v_26) {
                                                         _fx_free_N10Ast__exp_t(&v_26);
                                                      }
                                                      _fx_free_T2LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_tB(
                                                         &v_25);
                                                   }
                                                   else {
                                                      _fx_LN10Ast__typ_t args_0 = 0;
                                                      _fx_N10Ast__exp_t v_55 = 0;
                                                      _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t __fold_result___2 = {0};
                                                      _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t v_56 = {0};
                                                      _fx_LN10Ast__pat_t al_2 = 0;
                                                      _fx_LN10Ast__pat_t bl_2 = 0;
                                                      _fx_N10Ast__exp_t cmp_code_3 = 0;
                                                      _fx_LN10Ast__pat_t v_57 = 0;
                                                      _fx_N10Ast__pat_t a_case_pat_1 = 0;
                                                      _fx_LN10Ast__pat_t v_58 = 0;
                                                      _fx_N10Ast__pat_t b_case_pat_1 = 0;
                                                      _fx_LN10Ast__pat_t v_59 = 0;
                                                      _fx_N10Ast__pat_t ab_case_pat_1 = 0;
                                                      _fx_T2N10Ast__pat_tN10Ast__exp_t v_60 = {0};
                                                      if (FX_REC_VARIANT_TAG(t_1) == 17) {
                                                         FX_COPY_PTR(t_1->u.TypTuple, &args_0);
                                                      }
                                                      else {
                                                         FX_CALL(_fx_cons_LN10Ast__typ_t(t_1, 0, true, &args_0), _fx_catch_5);

                                                      _fx_catch_5: ;
                                                      }
                                                      FX_CHECK_EXN(_fx_catch_7);
                                                      FX_CALL(_fx_M3AstFM6ExpNopN10Ast__exp_t1RM5loc_t(&body_loc_0, &v_55),
                                                         _fx_catch_7);
                                                      _fx_make_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(0, 0, v_55,
                                                         &__fold_result___2);
                                                      int_ v_61;
                                                      FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(args_0, &v_61, 0),
                                                         _fx_catch_7);
                                                      for (int_ idx_1 = 0; idx_1 < v_61; idx_1++) {
                                                         _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t v_62 = {0};
                                                         _fx_LN10Ast__pat_t al_3 = 0;
                                                         _fx_LN10Ast__pat_t bl_3 = 0;
                                                         _fx_N10Ast__exp_t cmp_code_4 = 0;
                                                         fx_str_t v_63 = {0};
                                                         fx_str_t v_64 = {0};
                                                         fx_str_t v_65 = {0};
                                                         fx_str_t v_66 = {0};
                                                         fx_str_t v_67 = {0};
                                                         fx_str_t v_68 = {0};
                                                         _fx_N13Ast__binary_t v_69 = 0;
                                                         _fx_N10Ast__typ_t v_70 = 0;
                                                         _fx_T2N10Ast__typ_tR10Ast__loc_t v_71 = {0};
                                                         _fx_N10Ast__exp_t v_72 = 0;
                                                         _fx_N10Ast__typ_t v_73 = 0;
                                                         _fx_T2N10Ast__typ_tR10Ast__loc_t v_74 = {0};
                                                         _fx_N10Ast__exp_t v_75 = 0;
                                                         _fx_T2N10Ast__typ_tR10Ast__loc_t v_76 = {0};
                                                         _fx_N10Ast__exp_t cmp_ab_1 = 0;
                                                         _fx_N10Ast__exp_t cmp_code_5 = 0;
                                                         _fx_T2N10Ast__typ_tR10Ast__loc_t v_77 = {0};
                                                         _fx_N10Ast__pat_t v_78 = 0;
                                                         _fx_N10Ast__pat_t v_79 = 0;
                                                         _fx_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t v_80 = {0};
                                                         _fx_copy_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(
                                                            &__fold_result___2, &v_62);
                                                         FX_COPY_PTR(v_62.t0, &al_3);
                                                         FX_COPY_PTR(v_62.t1, &bl_3);
                                                         FX_COPY_PTR(v_62.t2, &cmp_code_4);
                                                         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&astr_0, &v_63, 0),
                                                            _fx_catch_6);
                                                         FX_CALL(_fx_F6stringS1i(idx_1, &v_64, 0), _fx_catch_6);
                                                         {
                                                            const fx_str_t strs_2[] = { v_63, v_64 };
                                                            FX_CALL(fx_strjoin(0, 0, 0, strs_2, 2, &v_65), _fx_catch_6);
                                                         }
                                                         _fx_R9Ast__id_t ai_1;
                                                         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_65, &ai_1, 0), _fx_catch_6);
                                                         FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&bstr_0, &v_66, 0),
                                                            _fx_catch_6);
                                                         FX_CALL(_fx_F6stringS1i(idx_1, &v_67, 0), _fx_catch_6);
                                                         {
                                                            const fx_str_t strs_3[] = { v_66, v_67 };
                                                            FX_CALL(fx_strjoin(0, 0, 0, strs_3, 2, &v_68), _fx_catch_6);
                                                         }
                                                         _fx_R9Ast__id_t bi_1;
                                                         FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&v_68, &bi_1, 0), _fx_catch_6);
                                                         FX_CALL(
                                                            _fx_M3AstFM5OpCmpN13Ast__binary_t1N12Ast__cmpop_t(
                                                               &_fx_g20Ast_typecheck__CmpEQ, &v_69), _fx_catch_6);
                                                         FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_70, 0),
                                                            _fx_catch_6);
                                                         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_70, &body_loc_0, &v_71);
                                                         FX_CALL(
                                                            _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(
                                                               &ai_1, &v_71, &v_72), _fx_catch_6);
                                                         FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&v_73, 0),
                                                            _fx_catch_6);
                                                         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_73, &body_loc_0, &v_74);
                                                         FX_CALL(
                                                            _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(
                                                               &bi_1, &v_74, &v_75), _fx_catch_6);
                                                         _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g22Ast_typecheck__TypBool,
                                                            &body_loc_0, &v_76);
                                                         FX_CALL(
                                                            _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                               v_69, v_72, v_75, &v_76, &cmp_ab_1), _fx_catch_6);
                                                         if (idx_1 == 0) {
                                                            FX_COPY_PTR(cmp_ab_1, &cmp_code_5);
                                                         }
                                                         else {
                                                            _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g22Ast_typecheck__TypBool,
                                                               &body_loc_0, &v_77);
                                                            FX_CALL(
                                                               _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                                  _fx_g27Ast_typecheck__OpBitwiseAnd, cmp_code_4, cmp_ab_1,
                                                                  &v_77, &cmp_code_5), _fx_catch_6);
                                                         }
                                                         FX_CALL(
                                                            _fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&ai_1,
                                                               &body_loc_0, &v_78), _fx_catch_6);
                                                         FX_CALL(_fx_cons_LN10Ast__pat_t(v_78, al_3, false, &al_3),
                                                            _fx_catch_6);
                                                         FX_CALL(
                                                            _fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&bi_1,
                                                               &body_loc_0, &v_79), _fx_catch_6);
                                                         FX_CALL(_fx_cons_LN10Ast__pat_t(v_79, bl_3, false, &bl_3),
                                                            _fx_catch_6);
                                                         _fx_make_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(al_3, bl_3,
                                                            cmp_code_5, &v_80);
                                                         _fx_free_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(
                                                            &__fold_result___2);
                                                         _fx_copy_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(&v_80,
                                                            &__fold_result___2);

                                                      _fx_catch_6: ;
                                                         _fx_free_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(&v_80);
                                                         if (v_79) {
                                                            _fx_free_N10Ast__pat_t(&v_79);
                                                         }
                                                         if (v_78) {
                                                            _fx_free_N10Ast__pat_t(&v_78);
                                                         }
                                                         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_77);
                                                         if (cmp_code_5) {
                                                            _fx_free_N10Ast__exp_t(&cmp_code_5);
                                                         }
                                                         if (cmp_ab_1) {
                                                            _fx_free_N10Ast__exp_t(&cmp_ab_1);
                                                         }
                                                         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_76);
                                                         if (v_75) {
                                                            _fx_free_N10Ast__exp_t(&v_75);
                                                         }
                                                         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_74);
                                                         if (v_73) {
                                                            _fx_free_N10Ast__typ_t(&v_73);
                                                         }
                                                         if (v_72) {
                                                            _fx_free_N10Ast__exp_t(&v_72);
                                                         }
                                                         _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_71);
                                                         if (v_70) {
                                                            _fx_free_N10Ast__typ_t(&v_70);
                                                         }
                                                         if (v_69) {
                                                            _fx_free_N13Ast__binary_t(&v_69);
                                                         }
                                                         FX_FREE_STR(&v_68);
                                                         FX_FREE_STR(&v_67);
                                                         FX_FREE_STR(&v_66);
                                                         FX_FREE_STR(&v_65);
                                                         FX_FREE_STR(&v_64);
                                                         FX_FREE_STR(&v_63);
                                                         if (cmp_code_4) {
                                                            _fx_free_N10Ast__exp_t(&cmp_code_4);
                                                         }
                                                         if (bl_3) {
                                                            _fx_free_LN10Ast__pat_t(&bl_3);
                                                         }
                                                         if (al_3) {
                                                            _fx_free_LN10Ast__pat_t(&al_3);
                                                         }
                                                         _fx_free_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(&v_62);
                                                         FX_CHECK_EXN(_fx_catch_7);
                                                      }
                                                      _fx_copy_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(&__fold_result___2,
                                                         &v_56);
                                                      FX_COPY_PTR(v_56.t0, &al_2);
                                                      FX_COPY_PTR(v_56.t1, &bl_2);
                                                      FX_COPY_PTR(v_56.t2, &cmp_code_3);
                                                      FX_CALL(
                                                         _fx_M13Ast_typecheckFM3revLN10Ast__pat_t1LN10Ast__pat_t(al_2, &v_57,
                                                            0), _fx_catch_7);
                                                      FX_CALL(
                                                         _fx_M3AstFM10PatVariantN10Ast__pat_t3RM4id_tLN10Ast__pat_tRM5loc_t(n_0,
                                                            v_57, &body_loc_0, &a_case_pat_1), _fx_catch_7);
                                                      FX_CALL(
                                                         _fx_M13Ast_typecheckFM3revLN10Ast__pat_t1LN10Ast__pat_t(bl_2, &v_58,
                                                            0), _fx_catch_7);
                                                      FX_CALL(
                                                         _fx_M3AstFM10PatVariantN10Ast__pat_t3RM4id_tLN10Ast__pat_tRM5loc_t(n_0,
                                                            v_58, &body_loc_0, &b_case_pat_1), _fx_catch_7);
                                                      FX_CALL(_fx_cons_LN10Ast__pat_t(b_case_pat_1, 0, true, &v_59),
                                                         _fx_catch_7);
                                                      FX_CALL(_fx_cons_LN10Ast__pat_t(a_case_pat_1, v_59, false, &v_59),
                                                         _fx_catch_7);
                                                      FX_CALL(
                                                         _fx_M3AstFM8PatTupleN10Ast__pat_t2LN10Ast__pat_tRM5loc_t(v_59,
                                                            &body_loc_0, &ab_case_pat_1), _fx_catch_7);
                                                      _fx_make_T2N10Ast__pat_tN10Ast__exp_t(ab_case_pat_1, cmp_code_3, &v_60);
                                                      FX_CALL(
                                                         _fx_cons_LT2N10Ast__pat_tN10Ast__exp_t(&v_60, complex_cases_1, true,
                                                            &v_24), _fx_catch_7);

                                                   _fx_catch_7: ;
                                                      _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&v_60);
                                                      if (ab_case_pat_1) {
                                                         _fx_free_N10Ast__pat_t(&ab_case_pat_1);
                                                      }
                                                      if (v_59) {
                                                         _fx_free_LN10Ast__pat_t(&v_59);
                                                      }
                                                      if (b_case_pat_1) {
                                                         _fx_free_N10Ast__pat_t(&b_case_pat_1);
                                                      }
                                                      if (v_58) {
                                                         _fx_free_LN10Ast__pat_t(&v_58);
                                                      }
                                                      if (a_case_pat_1) {
                                                         _fx_free_N10Ast__pat_t(&a_case_pat_1);
                                                      }
                                                      if (v_57) {
                                                         _fx_free_LN10Ast__pat_t(&v_57);
                                                      }
                                                      if (cmp_code_3) {
                                                         _fx_free_N10Ast__exp_t(&cmp_code_3);
                                                      }
                                                      if (bl_2) {
                                                         _fx_free_LN10Ast__pat_t(&bl_2);
                                                      }
                                                      if (al_2) {
                                                         _fx_free_LN10Ast__pat_t(&al_2);
                                                      }
                                                      _fx_free_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(&v_56);
                                                      _fx_free_T3LN10Ast__pat_tLN10Ast__pat_tN10Ast__exp_t(&__fold_result___2);
                                                      if (v_55) {
                                                         _fx_free_N10Ast__exp_t(&v_55);
                                                      }
                                                      if (args_0) {
                                                         _fx_free_LN10Ast__typ_t(&args_0);
                                                      }
                                                   }
                                                   FX_CHECK_EXN(_fx_catch_8);
                                                   _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&__fold_result___0);
                                                   FX_COPY_PTR(v_24, &__fold_result___0);

                                                _fx_catch_8: ;
                                                   if (v_24) {
                                                      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&v_24);
                                                   }
                                                   if (t_1) {
                                                      _fx_free_N10Ast__typ_t(&t_1);
                                                   }
                                                   if (complex_cases_1) {
                                                      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&complex_cases_1);
                                                   }
                                                   if (t_orig_0) {
                                                      _fx_free_N10Ast__typ_t(&t_orig_0);
                                                   }
                                                   FX_CHECK_EXN(_fx_catch_10);
                                                }
                                                int s_0 = !lst_0 + !lst_1;
                                                FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_10);
                                                FX_COPY_PTR(__fold_result___0, &complex_cases_0);
                                                _fx_R9Ast__id_t v_81;
                                                FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&astr_0, &v_81, 0), _fx_catch_10);
                                                _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t1_0, &body_loc_0, &v_12);
                                                FX_CALL(
                                                   _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&v_81,
                                                      &v_12, &a_0), _fx_catch_10);
                                                _fx_R9Ast__id_t v_82;
                                                FX_CALL(_fx_M3AstFM6get_idRM4id_t1S(&bstr_0, &v_82, 0), _fx_catch_10);
                                                _fx_make_T2N10Ast__typ_tR10Ast__loc_t(t1_0, &body_loc_0, &v_13);
                                                FX_CALL(
                                                   _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(&v_82,
                                                      &v_13, &b_0), _fx_catch_10);
                                                _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g24Ast_typecheck__TypString,
                                                   &body_loc_0, &v_14);
                                                FX_CALL(
                                                   _fx_M3AstFM8ExpIdentN10Ast__exp_t2RM4id_tT2N10Ast__typ_tRM5loc_t(
                                                      &_fx_g15Ast__std__tag__, &v_14, &tag_0), _fx_catch_10);
                                                _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &body_loc_0,
                                                   &v_15);
                                                FX_CALL(
                                                   _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                      a_0, tag_0, &v_15, &a_tag_0), _fx_catch_10);
                                                _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g21Ast_typecheck__TypInt, &body_loc_0,
                                                   &v_16);
                                                FX_CALL(
                                                   _fx_M3AstFM6ExpMemN10Ast__exp_t3N10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                      b_0, tag_0, &v_16, &b_tag_0), _fx_catch_10);
                                                FX_CALL(
                                                   _fx_M3AstFM5OpCmpN13Ast__binary_t1N12Ast__cmpop_t(
                                                      &_fx_g20Ast_typecheck__CmpEQ, &v_17), _fx_catch_10);
                                                _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g22Ast_typecheck__TypBool,
                                                   &body_loc_0, &v_18);
                                                FX_CALL(
                                                   _fx_M3AstFM9ExpBinaryN10Ast__exp_t4N13Ast__binary_tN10Ast__exp_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                      v_17, a_tag_0, b_tag_0, &v_18, &cmp_tags_0), _fx_catch_10);
                                                if (complex_cases_0 == 0) {
                                                   FX_COPY_PTR(cmp_tags_0, &inst_body_1);
                                                }
                                                else {
                                                   _fx_N10Ast__pat_t v_83 = 0;
                                                   _fx_T2N10Ast__pat_tN10Ast__exp_t default_case_0 = {0};
                                                   _fx_LN10Ast__exp_t v_84 = 0;
                                                   _fx_LN10Ast__typ_t v_85 = 0;
                                                   _fx_N10Ast__typ_t v_86 = 0;
                                                   _fx_T2N10Ast__typ_tR10Ast__loc_t v_87 = {0};
                                                   _fx_N10Ast__exp_t ab_0 = 0;
                                                   _fx_LT2N10Ast__pat_tN10Ast__exp_t v_88 = 0;
                                                   _fx_LT2N10Ast__pat_tN10Ast__exp_t v_89 = 0;
                                                   _fx_T2N10Ast__typ_tR10Ast__loc_t v_90 = {0};
                                                   FX_CALL(_fx_M3AstFM6PatAnyN10Ast__pat_t1RM5loc_t(&body_loc_0, &v_83),
                                                      _fx_catch_9);
                                                   _fx_make_T2N10Ast__pat_tN10Ast__exp_t(v_83, cmp_tags_0, &default_case_0);
                                                   FX_CALL(_fx_cons_LN10Ast__exp_t(b_0, 0, true, &v_84), _fx_catch_9);
                                                   FX_CALL(_fx_cons_LN10Ast__exp_t(a_0, v_84, false, &v_84), _fx_catch_9);
                                                   FX_CALL(_fx_cons_LN10Ast__typ_t(t1_0, 0, true, &v_85), _fx_catch_9);
                                                   FX_CALL(_fx_cons_LN10Ast__typ_t(t1_0, v_85, false, &v_85), _fx_catch_9);
                                                   FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(v_85, &v_86),
                                                      _fx_catch_9);
                                                   _fx_make_T2N10Ast__typ_tR10Ast__loc_t(v_86, &body_loc_0, &v_87);
                                                   FX_CALL(
                                                      _fx_M3AstFM10ExpMkTupleN10Ast__exp_t2LN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                         v_84, &v_87, &ab_0), _fx_catch_9);
                                                   FX_CALL(
                                                      _fx_cons_LT2N10Ast__pat_tN10Ast__exp_t(&default_case_0, complex_cases_0,
                                                         true, &v_88), _fx_catch_9);
                                                   FX_CALL(
                                                      _fx_M13Ast_typecheckFM3revLT2N10Ast__pat_tN10Ast__exp_t1LT2N10Ast__pat_tN10Ast__exp_t(
                                                         v_88, &v_89, 0), _fx_catch_9);
                                                   _fx_make_T2N10Ast__typ_tR10Ast__loc_t(_fx_g22Ast_typecheck__TypBool,
                                                      &body_loc_0, &v_90);
                                                   FX_CALL(
                                                      _fx_M3AstFM8ExpMatchN10Ast__exp_t3N10Ast__exp_tLT2N10Ast__pat_tN10Ast__exp_tT2N10Ast__typ_tRM5loc_t(
                                                         ab_0, v_89, &v_90, &inst_body_1), _fx_catch_9);

                                                _fx_catch_9: ;
                                                   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_90);
                                                   if (v_89) {
                                                      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&v_89);
                                                   }
                                                   if (v_88) {
                                                      _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&v_88);
                                                   }
                                                   if (ab_0) {
                                                      _fx_free_N10Ast__exp_t(&ab_0);
                                                   }
                                                   _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_87);
                                                   if (v_86) {
                                                      _fx_free_N10Ast__typ_t(&v_86);
                                                   }
                                                   if (v_85) {
                                                      _fx_free_LN10Ast__typ_t(&v_85);
                                                   }
                                                   if (v_84) {
                                                      _fx_free_LN10Ast__exp_t(&v_84);
                                                   }
                                                   _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&default_case_0);
                                                   if (v_83) {
                                                      _fx_free_N10Ast__pat_t(&v_83);
                                                   }
                                                }
                                                FX_CHECK_EXN(_fx_catch_10);
                                                FX_CALL(
                                                   _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
                                                      inst_body_1, inst_env_0, fun_sc_0, fx_result, 0), _fx_catch_10);

                                             _fx_catch_10: ;
                                                if (inst_body_1) {
                                                   _fx_free_N10Ast__exp_t(&inst_body_1);
                                                }
                                                if (cmp_tags_0) {
                                                   _fx_free_N10Ast__exp_t(&cmp_tags_0);
                                                }
                                                _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_18);
                                                if (v_17) {
                                                   _fx_free_N13Ast__binary_t(&v_17);
                                                }
                                                if (b_tag_0) {
                                                   _fx_free_N10Ast__exp_t(&b_tag_0);
                                                }
                                                _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_16);
                                                if (a_tag_0) {
                                                   _fx_free_N10Ast__exp_t(&a_tag_0);
                                                }
                                                _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_15);
                                                if (tag_0) {
                                                   _fx_free_N10Ast__exp_t(&tag_0);
                                                }
                                                _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_14);
                                                if (b_0) {
                                                   _fx_free_N10Ast__exp_t(&b_0);
                                                }
                                                _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_13);
                                                if (a_0) {
                                                   _fx_free_N10Ast__exp_t(&a_0);
                                                }
                                                _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_12);
                                                if (complex_cases_0) {
                                                   _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&complex_cases_0);
                                                }
                                                if (__fold_result___0) {
                                                   _fx_free_LT2N10Ast__pat_tN10Ast__exp_t(&__fold_result___0);
                                                }
                                                if (proto_cases_0) {
                                                   _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&proto_cases_0);
                                                }
                                                FX_FREE_LIST_SIMPLE(&var_ctors_0);
                                                _fx_free_R17Ast__defvariant_t(&v_11);
                                                _fx_free_T2LR9Ast__id_tLT2R9Ast__id_tN10Ast__typ_t(&v_10);
                                                _fx_free_N14Ast__id_info_t(&v_9);
                                                FX_FREE_STR(&bstr_0);
                                                FX_FREE_STR(&astr_0);
                                                goto _fx_endmatch_1;
                                             }
                                          }
                                       }
                                    }
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }
      _fx_N10Ast__pat_t v_91 = 0;
      fx_str_t v_92 = {0};
      fx_str_t v_93 = {0};
      fx_str_t v_94 = {0};
      fx_exn_t v_95 = {0};
      fx_str_t slit_5 =
         FX_MAKE_STR("patterns: \n"
            U"\t");
      FX_CALL(_fx_M13Ast_typecheckFM5printv1S(&slit_5, 0), _fx_catch_11);
      FX_CALL(_fx_M3AstFM8PatTupleN10Ast__pat_t2LN10Ast__pat_tRM5loc_t(inst_args_0, inst_loc_0, &v_91), _fx_catch_11);
      FX_CALL(_fx_M6Ast_ppFM12pprint_pat_xv1N10Ast__pat_t(v_91, 0), _fx_catch_11);
      FX_CALL(_fx_M3AstFM7typ2strS1N10Ast__typ_t(ftyp_0, &v_92, 0), _fx_catch_11);
      FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_92, &v_93, 0), _fx_catch_11);
      fx_str_t slit_6 = FX_MAKE_STR("__eq_variants__ has improper type ");
      fx_str_t slit_7 = FX_MAKE_STR("; should be (variant_type, variant_type)->bool");
      {
         const fx_str_t strs_4[] = { slit_6, v_93, slit_7 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_4, 3, &v_94), _fx_catch_11);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(inst_loc_0, &v_94, &v_95, 0), _fx_catch_11);
      FX_THROW(&v_95, false, _fx_catch_11);

   _fx_catch_11: ;
      fx_free_exn(&v_95);
      FX_FREE_STR(&v_94);
      FX_FREE_STR(&v_93);
      FX_FREE_STR(&v_92);
      if (v_91) {
         _fx_free_N10Ast__pat_t(&v_91);
      }

   _fx_endmatch_1: ;
      FX_CHECK_EXN(_fx_catch_12);

   _fx_catch_12: ;
      _fx_free_N14Ast__id_info_t(&v_1);
      goto _fx_endmatch_2;
   }
   FX_CALL(
      _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
         inst_body_0, inst_env_0, fun_sc_0, fx_result, 0), _fx_catch_13);

_fx_catch_13: ;

_fx_endmatch_2: ;

_fx_cleanup: ;
   if (ftyp_0) {
      _fx_free_N10Ast__typ_t(&ftyp_0);
   }
   FX_FREE_STR(&v_0);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM19instantiate_variantT2R9Ast__id_tN10Ast__typ_t5LN10Ast__typ_trR17Ast__defvariant_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_LN10Ast__typ_t_data_t* ty_args_0,
   struct _fx_rR17Ast__defvariant_t_data_t* dvar_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_T2R9Ast__id_tN10Ast__typ_t* fx_result,
   void* fx_fv)
{
   _fx_LN12Ast__scope_t dvar_scope_0 = 0;
   _fx_LT2R9Ast__id_tLTa2R9Ast__id_t dvar_ifaces_0 = 0;
   _fx_LR9Ast__id_t dvar_ctors_0 = 0;
   _fx_LT2R9Ast__id_tN10Ast__typ_t dvar_cases_0 = 0;
   _fx_N10Ast__typ_t dvar_alias_0 = 0;
   _fx_LR9Ast__id_t dvar_templ_args_0 = 0;
   _fx_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t v_0 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   _fx_N10Ast__typ_t inst_app_typ_0 = 0;
   _fx_rR17Ast__defvariant_t inst_dvar_0 = 0;
   _fx_LT2R9Ast__id_tLTa2R9Ast__id_t new_ifaces_0 = 0;
   _fx_Nt10Hashset__t1R9Ast__id_t prev_ifaces_0 = 0;
   _fx_N14Ast__id_info_t v_1 = {0};
   _fx_rLR9Ast__id_t v_2 = 0;
   _fx_LR9Ast__id_t v_3 = 0;
   _fx_rLR9Ast__id_t v_4 = 0;
   _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t v_5 = {0};
   _fx_LT2R9Ast__id_tN10Ast__typ_t lst_0 = 0;
   _fx_LR9Ast__id_t lst_1 = 0;
   _fx_LT2R9Ast__id_tN10Ast__typ_t inst_cases_0 = 0;
   _fx_LR9Ast__id_t inst_ctors_0 = 0;
   _fx_R17Ast__defvariant_t v_6 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_R17Ast__defvariant_t* v_7 = &dvar_0->data;
   _fx_R10Ast__loc_t dvar_loc_0 = v_7->dvar_loc;
   FX_COPY_PTR(v_7->dvar_scope, &dvar_scope_0);
   FX_COPY_PTR(v_7->dvar_ifaces, &dvar_ifaces_0);
   FX_COPY_PTR(v_7->dvar_ctors, &dvar_ctors_0);
   FX_COPY_PTR(v_7->dvar_cases, &dvar_cases_0);
   _fx_R16Ast__var_flags_t dvar_flags_0 = v_7->dvar_flags;
   FX_COPY_PTR(v_7->dvar_alias, &dvar_alias_0);
   FX_COPY_PTR(v_7->dvar_templ_args, &dvar_templ_args_0);
   _fx_R9Ast__id_t dvar_name_0 = v_7->dvar_name;
   if (ty_args_0 == 0) {
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t __fold_result___0 = {0};
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &__fold_result___0);
      _fx_LR9Ast__id_t lst_2 = dvar_templ_args_0;
      for (; lst_2; lst_2 = lst_2->tl) {
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_3 = {0};
         _fx_N10Ast__typ_t v_8 = 0;
         _fx_LN16Ast__env_entry_t entries_0 = 0;
         _fx_N16Ast__env_entry_t v_9 = 0;
         _fx_LN16Ast__env_entry_t v_10 = 0;
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_11 = 0;
         _fx_FPi2R9Ast__id_tR9Ast__id_t v_12 = {0};
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_13 = 0;
         _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_14 = {0};
         _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
         _fx_FPi2R9Ast__id_tR9Ast__id_t v_15 = {0};
         _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_16 = {0};
         _fx_R9Ast__id_t* tn_0 = &lst_2->hd;
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_3);
         FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, tn_0, &v_8), _fx_catch_1);
         FX_CALL(
            _fx_M13Ast_typecheckFM8find_allLN16Ast__env_entry_t2R9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(tn_0,
               &env_3, &entries_0, 0), _fx_catch_1);
         FX_CALL(_fx_M3AstFM6EnvTypN16Ast__env_entry_t1N10Ast__typ_t(v_8, &v_9), _fx_catch_1);
         FX_CALL(_fx_cons_LN16Ast__env_entry_t(v_9, entries_0, true, &v_10), _fx_catch_1);
         FX_COPY_PTR(env_3.root, &v_11);
         FX_COPY_FP(&env_3.cmp, &v_12);
         FX_CALL(
            _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
               v_11, tn_0, v_10, &v_12, &v_13, 0), _fx_catch_1);
         if ((v_13 != 0) + 1 == 2) {
            _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
               vcase_0 = &v_13->u.Node;
            if (vcase_0->t0.tag == 1) {
               _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_17 = 0;
               FX_CALL(
                  _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                     &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_17), _fx_catch_0);
               _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_17, false, &v_14);

            _fx_catch_0: ;
               if (v_17) {
                  _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_17);
               }
               goto _fx_endmatch_0;
            }
         }
         _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_13, true, &v_14);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_1);
         FX_COPY_PTR(v_14.t0, &new_root_0);
         FX_COPY_FP(&env_3.cmp, &v_15);
         _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_15, &v_16);
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
         _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_16, &__fold_result___0);

      _fx_catch_1: ;
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_16);
         FX_FREE_FP(&v_15);
         if (new_root_0) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
         }
         _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_14);
         if (v_13) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_13);
         }
         FX_FREE_FP(&v_12);
         if (v_11) {
            _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_11);
         }
         if (v_10) {
            _fx_free_LN16Ast__env_entry_t(&v_10);
         }
         if (v_9) {
            _fx_free_N16Ast__env_entry_t(&v_9);
         }
         if (entries_0) {
            _fx_free_LN16Ast__env_entry_t(&entries_0);
         }
         if (v_8) {
            _fx_free_N10Ast__typ_t(&v_8);
         }
         _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_3);
         FX_CHECK_EXN(_fx_catch_2);
      }
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0, &env_2);
      _fx_make_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t(false, &env_2,
         &dvar_name_0, dvar_alias_0, dvar_0, &v_0);

   _fx_catch_2: ;
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&__fold_result___0);
   }
   else {
      _fx_N10Ast__typ_t inst_app_typ_1 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_18 = {0};
      _fx_rLR9Ast__id_t v_19 = 0;
      _fx_R17Ast__defvariant_t v_20 = {0};
      _fx_rR17Ast__defvariant_t v_21 = 0;
      int_ v_22;
      FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(dvar_scope_0, &v_22, 0), _fx_catch_3);
      _fx_R9Ast__id_t inst_name_0;
      FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(v_22, &dvar_name_0, &inst_name_0, 0), _fx_catch_3);
      FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(ty_args_0, &dvar_name_0, &inst_app_typ_1), _fx_catch_3);
      FX_CALL(
         _fx_M13Ast_typecheckFM19match_ty_templ_argsRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t5LN10Ast__typ_tLR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR10Ast__loc_tR10Ast__loc_t(
            ty_args_0, dvar_templ_args_0, env_0, &dvar_loc_0, loc_0, &v_18, 0), _fx_catch_3);
      _fx_R16Ast__var_flags_t v_23 =
         { dvar_flags_0.var_flag_class_from, dvar_flags_0.var_flag_record, dvar_flags_0.var_flag_recursive,
            dvar_flags_0.var_flag_have_tag, dvar_flags_0.var_flag_have_mutable, dvar_flags_0.var_flag_opt, true };
      FX_CALL(_fx_make_rLR9Ast__id_t(0, &v_19), _fx_catch_3);
      _fx_make_R17Ast__defvariant_t(&inst_name_0, 0, inst_app_typ_1, &v_23, dvar_cases_0, dvar_ctors_0, v_19, dvar_ifaces_0,
         dvar_scope_0, loc_0, &v_20);
      FX_CALL(_fx_make_rR17Ast__defvariant_t(&v_20, &v_21), _fx_catch_3);
      _fx_make_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t(true, &v_18,
         &inst_name_0, inst_app_typ_1, v_21, &v_0);

   _fx_catch_3: ;
      if (v_21) {
         _fx_free_rR17Ast__defvariant_t(&v_21);
      }
      _fx_free_R17Ast__defvariant_t(&v_20);
      if (v_19) {
         _fx_free_rLR9Ast__id_t(&v_19);
      }
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_18);
      if (inst_app_typ_1) {
         _fx_free_N10Ast__typ_t(&inst_app_typ_1);
      }
   }
   FX_CHECK_EXN(_fx_cleanup);
   bool instantiate_0 = v_0.t0;
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0.t1, &env_1);
   _fx_R9Ast__id_t inst_name_1 = v_0.t2;
   FX_COPY_PTR(v_0.t3, &inst_app_typ_0);
   FX_COPY_PTR(v_0.t4, &inst_dvar_0);
   if (dvar_ifaces_0 == 0) {
      FX_COPY_PTR(dvar_ifaces_0, &new_ifaces_0);
   }
   else {
      FX_CALL(_fx_M3AstFM16empty_id_hashsetNt10Hashset__t1RM4id_t1i(8, &prev_ifaces_0, 0), _fx_cleanup);
      _fx_LT2R9Ast__id_tLTa2R9Ast__id_t lstend_0 = 0;
      _fx_LT2R9Ast__id_tLTa2R9Ast__id_t lst_3 = dvar_ifaces_0;
      for (; lst_3; lst_3 = lst_3->tl) {
         _fx_N10Ast__typ_t v_24 = 0;
         _fx_N10Ast__typ_t v_25 = 0;
         _fx_rR19Ast__definterface_t iface_0 = 0;
         fx_arr_t table_0 = {0};
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t v_26 = 0;
         _fx_LTa2R9Ast__id_t v_27 = 0;
         _fx_T2R9Ast__id_tLTa2R9Ast__id_t tup_0 = {0};
         _fx_T2R9Ast__id_tLTa2R9Ast__id_t* __pat___0 = &lst_3->hd;
         _fx_R9Ast__id_t iname_0 = __pat___0->t0;
         FX_CALL(_fx_M3AstFM6TypAppN10Ast__typ_t2LN10Ast__typ_tRM4id_t(0, &iname_0, &v_24), _fx_catch_8);
         FX_CALL(
            _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               v_24, &env_1, dvar_scope_0, &dvar_loc_0, &v_25, 0), _fx_catch_8);
         if (FX_REC_VARIANT_TAG(v_25) == 24) {
            _fx_T2LN10Ast__typ_tR9Ast__id_t* vcase_1 = &v_25->u.TypApp;
            if (vcase_1->t0 == 0) {
               FX_CALL(_fx_M3AstFM9get_ifacerRM14definterface_t2RM4id_tRM5loc_t(&vcase_1->t1, &dvar_loc_0, &iface_0, 0),
                  _fx_catch_4);

            _fx_catch_4: ;
               goto _fx_endmatch_1;
            }
         }
         fx_str_t v_28 = {0};
         fx_str_t v_29 = {0};
         fx_str_t v_30 = {0};
         fx_str_t v_31 = {0};
         fx_exn_t v_32 = {0};
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&dvar_name_0, &v_28, 0), _fx_catch_5);
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&iname_0, &v_29, 0), _fx_catch_5);
         FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&iname_0, &v_30, 0), _fx_catch_5);
         fx_str_t slit_0 = FX_MAKE_STR("variant \'");
         fx_str_t slit_1 = FX_MAKE_STR("\' claims to implement \'");
         fx_str_t slit_2 = FX_MAKE_STR("\', but \'");
         fx_str_t slit_3 = FX_MAKE_STR("\' is not an interface");
         {
            const fx_str_t strs_0[] = { slit_0, v_28, slit_1, v_29, slit_2, v_30, slit_3 };
            FX_CALL(fx_strjoin(0, 0, 0, strs_0, 7, &v_31), _fx_catch_5);
         }
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&dvar_loc_0, &v_31, &v_32, 0), _fx_catch_5);
         FX_THROW(&v_32, false, _fx_catch_5);

      _fx_catch_5: ;
         fx_free_exn(&v_32);
         FX_FREE_STR(&v_31);
         FX_FREE_STR(&v_30);
         FX_FREE_STR(&v_29);
         FX_FREE_STR(&v_28);

      _fx_endmatch_1: ;
         FX_CHECK_EXN(_fx_catch_8);
         _fx_R9Ast__id_t iname1_0 = iface_0->data.di_name;
         fx_copy_arr(&prev_ifaces_0->u.t.t5, &table_0);
         int_ v_33 = prev_ifaces_0->u.t.t2;
         for (int_ j_0 = 0; j_0 < v_33; j_0++) {
            FX_CHKIDX(FX_CHKIDX1(table_0, 0, j_0), _fx_catch_6);
            if (FX_PTR_1D(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t, table_0, j_0)->hv < 9223372036854775808ULL) {
               FX_CHKIDX(FX_CHKIDX1(table_0, 0, j_0), _fx_catch_6);
               _fx_R9Ast__id_t v_34 = FX_PTR_1D(_fx_Rt24Hashset__hashset_entry_t1R9Ast__id_t, table_0, j_0)->key;
               FX_CALL(
                  _fx_M13Ast_typecheckFM10__lambda__v5R9Ast__id_tR10Ast__loc_tR9Ast__id_tR9Ast__id_tR10Ast__loc_t(&v_34,
                     &dvar_loc_0, &dvar_name_0, &iname1_0, loc_0, 0), _fx_catch_6);
            }

         _fx_catch_6: ;
            FX_CHECK_EXN(_fx_catch_8);
         }
         FX_CALL(_fx_M13Ast_typecheckFM3addv2Nt10Hashset__t1R9Ast__id_tR9Ast__id_t(prev_ifaces_0, &iname1_0, 0), _fx_catch_8);
         FX_COPY_PTR(iface_0->data.di_all_methods, &v_26);
         _fx_LTa2R9Ast__id_t lstend_1 = 0;
         _fx_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t lst_4 = v_26;
         for (; lst_4; lst_4 = lst_4->tl) {
            _fx_T3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t* __pat___1 = &lst_4->hd;
            _fx_R9Ast__id_t m_0 = __pat___1->t0;
            _fx_Ta2R9Ast__id_t tup_1 = { m_0, _fx_g9Ast__noid };
            _fx_LTa2R9Ast__id_t node_0 = 0;
            FX_CALL(_fx_cons_LTa2R9Ast__id_t(&tup_1, 0, false, &node_0), _fx_catch_7);
            FX_LIST_APPEND(v_27, lstend_1, node_0);

         _fx_catch_7: ;
            FX_CHECK_EXN(_fx_catch_8);
         }
         _fx_make_T2R9Ast__id_tLTa2R9Ast__id_t(&iname1_0, v_27, &tup_0);
         _fx_LT2R9Ast__id_tLTa2R9Ast__id_t node_1 = 0;
         FX_CALL(_fx_cons_LT2R9Ast__id_tLTa2R9Ast__id_t(&tup_0, 0, false, &node_1), _fx_catch_8);
         FX_LIST_APPEND(new_ifaces_0, lstend_0, node_1);

      _fx_catch_8: ;
         _fx_free_T2R9Ast__id_tLTa2R9Ast__id_t(&tup_0);
         FX_FREE_LIST_SIMPLE(&v_27);
         if (v_26) {
            _fx_free_LT3R9Ast__id_tN10Ast__typ_tR16Ast__fun_flags_t(&v_26);
         }
         FX_FREE_ARR(&table_0);
         if (iface_0) {
            _fx_free_rR19Ast__definterface_t(&iface_0);
         }
         if (v_25) {
            _fx_free_N10Ast__typ_t(&v_25);
         }
         if (v_24) {
            _fx_free_N10Ast__typ_t(&v_24);
         }
         FX_CHECK_EXN(_fx_cleanup);
      }
   }
   if (instantiate_0) {
      _fx_M3AstFM9IdVariantN14Ast__id_info_t1rRM12defvariant_t(inst_dvar_0, &v_1);
      FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&inst_name_1, &v_1, 0), _fx_cleanup);
      FX_COPY_PTR(dvar_0->data.dvar_templ_inst, &v_2);
      FX_COPY_PTR(v_2->data, &v_3);
      FX_CALL(_fx_cons_LR9Ast__id_t(&inst_name_1, v_3, false, &v_3), _fx_cleanup);
      FX_COPY_PTR(dvar_0->data.dvar_templ_inst, &v_4);
      _fx_LR9Ast__id_t* v_35 = &v_4->data;
      FX_FREE_LIST_SIMPLE(v_35);
      FX_COPY_PTR(v_3, v_35);
   }
   _fx_LT2R9Ast__id_tN10Ast__typ_t lstend_2 = 0;
   _fx_LR9Ast__id_t lstend_3 = 0;
   int_ idx_0 = 0;
   _fx_LT2R9Ast__id_tN10Ast__typ_t lst_5 = dvar_cases_0;
   _fx_LR9Ast__id_t lst_6 = dvar_ctors_0;
   for (; lst_5 && lst_6; lst_6 = lst_6->tl, lst_5 = lst_5->tl, idx_0 += 1) {
      _fx_N10Ast__typ_t t_0 = 0;
      _fx_N10Ast__typ_t v_36 = 0;
      _fx_N10Ast__typ_t t_1 = 0;
      _fx_N10Ast__typ_t t_2 = 0;
      _fx_LN10Ast__typ_t argtyps_0 = 0;
      _fx_LR9Ast__id_t v_37 = 0;
      _fx_T2R9Ast__id_tN10Ast__typ_t v_38 = {0};
      _fx_N14Ast__id_info_t v_39 = {0};
      _fx_T2R9Ast__id_tN10Ast__typ_t v_40 = {0};
      _fx_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t tup_2 = {0};
      _fx_R9Ast__id_t* ctor_name_0 = &lst_6->hd;
      _fx_T2R9Ast__id_tN10Ast__typ_t* __pat___2 = &lst_5->hd;
      _fx_R9Ast__id_t n_0 = __pat___2->t0;
      FX_COPY_PTR(__pat___2->t1, &t_0);
      int tag_0 = FX_REC_VARIANT_TAG(t_0);
      int_ nargs_0;
      if (tag_0 == 17) {
         nargs_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(t_0->u.TypTuple, 0);
      }
      else if (tag_0 == 13) {
         nargs_0 = 0;
      }
      else {
         nargs_0 = 1;
      }
      FX_CHECK_EXN(_fx_catch_13);
      FX_CALL(_fx_M3AstFM7dup_typN10Ast__typ_t1N10Ast__typ_t(t_0, &v_36, 0), _fx_catch_13);
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_typN10Ast__typ_t4N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
            v_36, &env_1, sc_0, loc_0, &t_1, 0), _fx_catch_13);
      FX_CALL(
         _fx_M13Ast_typecheckFM19finalize_record_typN10Ast__typ_t4Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_tN10Ast__typ_tLN12Ast__scope_tR10Ast__loc_t(
            &env_1, t_1, sc_0, loc_0, &t_2, 0), _fx_catch_13);
      int tag_1 = FX_REC_VARIANT_TAG(t_2);
      int_ nrealargs_0;
      if (tag_1 == 17) {
         nrealargs_0 = _fx_M13Ast_typecheckFM6lengthi1LN10Ast__typ_t(t_2->u.TypTuple, 0);
      }
      else if (tag_1 == 13) {
         nrealargs_0 = 0;
      }
      else {
         nrealargs_0 = 1;
      }
      FX_CHECK_EXN(_fx_catch_13);
      if (nargs_0 == 0) {
         if (FX_REC_VARIANT_TAG(t_2) == 13) {
            goto _fx_endmatch_2;
         }
      }
      if (nargs_0 == 1) {
         FX_CALL(_fx_cons_LN10Ast__typ_t(t_2, 0, true, &argtyps_0), _fx_catch_9);  _fx_catch_9: ; goto _fx_endmatch_2;
      }
      if (FX_REC_VARIANT_TAG(t_2) == 17) {
         if (nrealargs_0 == nargs_0) {
            FX_COPY_PTR(t_2->u.TypTuple, &argtyps_0); goto _fx_endmatch_2;
         }
      }
      fx_str_t v_41 = {0};
      fx_str_t v_42 = {0};
      fx_str_t v_43 = {0};
      fx_str_t v_44 = {0};
      fx_str_t v_45 = {0};
      fx_str_t v_46 = {0};
      fx_exn_t v_47 = {0};
      FX_CALL(_fx_M3AstFM6stringS1RM4id_t(ctor_name_0, &v_41, 0), _fx_catch_10);
      FX_CALL(_fx_M3AstFM6stringS1RM4id_t(&dvar_name_0, &v_42, 0), _fx_catch_10);
      FX_CALL(_fx_M3AstFM6stringS1RM5loc_t(&dvar_loc_0, &v_43, 0), _fx_catch_10);
      FX_CALL(_fx_F6stringS1i(nrealargs_0, &v_44, 0), _fx_catch_10);
      FX_CALL(_fx_F6stringS1i(nargs_0, &v_45, 0), _fx_catch_10);
      fx_str_t slit_4 = FX_MAKE_STR("cannot instantiate case \'");
      fx_str_t slit_5 = FX_MAKE_STR("\' of variant \'");
      fx_str_t slit_6 = FX_MAKE_STR("\' defined at \'");
      fx_str_t slit_7 = FX_MAKE_STR("\': wrong number of actual parameters ");
      fx_str_t slit_8 = FX_MAKE_STR(" (vs ");
      fx_str_t slit_9 = FX_MAKE_STR(" expected)");
      {
         const fx_str_t strs_1[] = { slit_4, v_41, slit_5, v_42, slit_6, v_43, slit_7, v_44, slit_8, v_45, slit_9 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_1, 11, &v_46), _fx_catch_10);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_46, &v_47, 0), _fx_catch_10);
      FX_THROW(&v_47, false, _fx_catch_10);

   _fx_catch_10: ;
      fx_free_exn(&v_47);
      FX_FREE_STR(&v_46);
      FX_FREE_STR(&v_45);
      FX_FREE_STR(&v_44);
      FX_FREE_STR(&v_43);
      FX_FREE_STR(&v_42);
      FX_FREE_STR(&v_41);

   _fx_endmatch_2: ;
      FX_CHECK_EXN(_fx_catch_13);
      _fx_N17Ast__fun_constr_t v_48;
      _fx_M3AstFM11CtorVariantN17Ast__fun_constr_t1i(idx_0 + 1, &v_48);
      FX_COPY_PTR(inst_dvar_0->data.dvar_templ_args, &v_37);
      FX_CALL(
         _fx_M13Ast_typecheckFM24register_typ_constructorT2R9Ast__id_tN10Ast__typ_t8R9Ast__id_tN17Ast__fun_constr_tLR9Ast__id_tLN10Ast__typ_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
            ctor_name_0, &v_48, v_37, argtyps_0, inst_app_typ_0, &env_1, dvar_scope_0, &dvar_loc_0, &v_38, 0), _fx_catch_13);
      _fx_R9Ast__id_t inst_cname_0 = v_38.t0;
      if (instantiate_0) {
         FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(ctor_name_0, loc_0, &v_39, 0), _fx_catch_13);
         if (v_39.tag == 3) {
            _fx_rLR9Ast__id_t v_49 = 0;
            _fx_LR9Ast__id_t v_50 = 0;
            _fx_rLR9Ast__id_t v_51 = 0;
            _fx_rR13Ast__deffun_t c_def_0 = v_39.u.IdFun;
            FX_COPY_PTR(c_def_0->data.df_templ_inst, &v_49);
            FX_COPY_PTR(v_49->data, &v_50);
            FX_CALL(_fx_cons_LR9Ast__id_t(&inst_cname_0, v_50, false, &v_50), _fx_catch_11);
            FX_COPY_PTR(c_def_0->data.df_templ_inst, &v_51);
            _fx_LR9Ast__id_t* v_52 = &v_51->data;
            FX_FREE_LIST_SIMPLE(v_52);
            FX_COPY_PTR(v_50, v_52);

         _fx_catch_11: ;
            if (v_51) {
               _fx_free_rLR9Ast__id_t(&v_51);
            }
            FX_FREE_LIST_SIMPLE(&v_50);
            if (v_49) {
               _fx_free_rLR9Ast__id_t(&v_49);
            }
         }
         else {
            fx_str_t v_53 = {0};
            fx_str_t v_54 = {0};
            fx_str_t v_55 = {0};
            fx_exn_t v_56 = {0};
            FX_CALL(_fx_M3AstFM6stringS1RM4id_t(ctor_name_0, &v_53, 0), _fx_catch_12);
            FX_CALL(_fx_M3AstFM6stringS1RM4id_t(&dvar_name_0, &v_54, 0), _fx_catch_12);
            fx_str_t slit_10 = FX_MAKE_STR("invalid constructor ");
            fx_str_t slit_11 = FX_MAKE_STR(" of variant ");
            {
               const fx_str_t strs_2[] = { slit_10, v_53, slit_11, v_54 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_2, 4, &v_55), _fx_catch_12);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_55, &v_56, 0), _fx_catch_12);
            FX_THROW(&v_56, false, _fx_catch_12);

         _fx_catch_12: ;
            fx_free_exn(&v_56);
            FX_FREE_STR(&v_55);
            FX_FREE_STR(&v_54);
            FX_FREE_STR(&v_53);
         }
         FX_CHECK_EXN(_fx_catch_13);
      }
      _fx_make_T2R9Ast__id_tN10Ast__typ_t(&n_0, t_2, &v_40);
      _fx_make_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&v_40, &inst_cname_0, &tup_2);
      _fx_LT2R9Ast__id_tN10Ast__typ_t node_2 = 0;
      FX_CALL(_fx_cons_LT2R9Ast__id_tN10Ast__typ_t(&tup_2.t0, 0, false, &node_2), _fx_catch_13);
      FX_LIST_APPEND(lst_0, lstend_2, node_2);
      _fx_LR9Ast__id_t node_3 = 0;
      FX_CALL(_fx_cons_LR9Ast__id_t(&tup_2.t1, 0, false, &node_3), _fx_catch_13);
      FX_LIST_APPEND(lst_1, lstend_3, node_3);

   _fx_catch_13: ;
      _fx_free_T2T2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(&tup_2);
      _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_40);
      _fx_free_N14Ast__id_info_t(&v_39);
      _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_38);
      FX_FREE_LIST_SIMPLE(&v_37);
      if (argtyps_0) {
         _fx_free_LN10Ast__typ_t(&argtyps_0);
      }
      if (t_2) {
         _fx_free_N10Ast__typ_t(&t_2);
      }
      if (t_1) {
         _fx_free_N10Ast__typ_t(&t_1);
      }
      if (v_36) {
         _fx_free_N10Ast__typ_t(&v_36);
      }
      if (t_0) {
         _fx_free_N10Ast__typ_t(&t_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }
   int s_0 = !lst_5 + !lst_6;
   FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_cleanup);
   _fx_make_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(lst_0, lst_1, &v_5);
   FX_COPY_PTR(v_5.t0, &inst_cases_0);
   FX_COPY_PTR(v_5.t1, &inst_ctors_0);
   _fx_R17Ast__defvariant_t* v_57 = &inst_dvar_0->data;
   _fx_make_R17Ast__defvariant_t(&v_57->dvar_name, v_57->dvar_templ_args, v_57->dvar_alias, &v_57->dvar_flags, inst_cases_0,
      inst_ctors_0, v_57->dvar_templ_inst, new_ifaces_0, v_57->dvar_scope, &v_57->dvar_loc, &v_6);
   _fx_R17Ast__defvariant_t* v_58 = &inst_dvar_0->data;
   _fx_free_R17Ast__defvariant_t(v_58);
   _fx_copy_R17Ast__defvariant_t(&v_6, v_58);
   _fx_make_T2R9Ast__id_tN10Ast__typ_t(&inst_name_1, inst_app_typ_0, fx_result);

_fx_cleanup: ;
   FX_FREE_LIST_SIMPLE(&dvar_scope_0);
   if (dvar_ifaces_0) {
      _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(&dvar_ifaces_0);
   }
   FX_FREE_LIST_SIMPLE(&dvar_ctors_0);
   if (dvar_cases_0) {
      _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&dvar_cases_0);
   }
   if (dvar_alias_0) {
      _fx_free_N10Ast__typ_t(&dvar_alias_0);
   }
   FX_FREE_LIST_SIMPLE(&dvar_templ_args_0);
   _fx_free_T5BRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tN10Ast__typ_trR17Ast__defvariant_t(&v_0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   if (inst_app_typ_0) {
      _fx_free_N10Ast__typ_t(&inst_app_typ_0);
   }
   if (inst_dvar_0) {
      _fx_free_rR17Ast__defvariant_t(&inst_dvar_0);
   }
   if (new_ifaces_0) {
      _fx_free_LT2R9Ast__id_tLTa2R9Ast__id_t(&new_ifaces_0);
   }
   if (prev_ifaces_0) {
      _fx_free_Nt10Hashset__t1R9Ast__id_t(&prev_ifaces_0);
   }
   _fx_free_N14Ast__id_info_t(&v_1);
   if (v_2) {
      _fx_free_rLR9Ast__id_t(&v_2);
   }
   FX_FREE_LIST_SIMPLE(&v_3);
   if (v_4) {
      _fx_free_rLR9Ast__id_t(&v_4);
   }
   _fx_free_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(&v_5);
   if (lst_0) {
      _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&lst_0);
   }
   FX_FREE_LIST_SIMPLE(&lst_1);
   if (inst_cases_0) {
      _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&inst_cases_0);
   }
   FX_FREE_LIST_SIMPLE(&inst_ctors_0);
   _fx_free_R17Ast__defvariant_t(&v_6);
   return fx_status;
}

static int _fx_M13Ast_typecheckFM10__lambda__v5R9Ast__id_tR10Ast__loc_tR9Ast__id_tR9Ast__id_tR10Ast__loc_t(
   struct _fx_R9Ast__id_t* iname2_0,
   struct _fx_R10Ast__loc_t* dvar_loc_0,
   struct _fx_R9Ast__id_t* dvar_name_0,
   struct _fx_R9Ast__id_t* iname1_0,
   struct _fx_R10Ast__loc_t* loc_0,
   void* fx_fv)
{
   fx_str_t v_0 = {0};
   fx_str_t v_1 = {0};
   fx_str_t v_2 = {0};
   fx_str_t v_3 = {0};
   fx_str_t v_4 = {0};
   fx_exn_t v_5 = {0};
   int fx_status = 0;
   bool f1_0;
   FX_CALL(_fx_M3AstFM14same_or_parentB3RM4id_tRM4id_tRM5loc_t(iname1_0, iname2_0, loc_0, &f1_0, 0), _fx_cleanup);
   bool f2_0;
   FX_CALL(_fx_M3AstFM14same_or_parentB3RM4id_tRM4id_tRM5loc_t(iname2_0, iname1_0, loc_0, &f2_0, 0), _fx_cleanup);
   bool t_0;
   if (f1_0) {
      t_0 = true;
   }
   else {
      t_0 = f2_0;
   }
   if (t_0) {
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(dvar_name_0, &v_0, 0), _fx_cleanup);
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(iname1_0, &v_1, 0), _fx_cleanup);
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(iname2_0, &v_2, 0), _fx_cleanup);
      _fx_R9Ast__id_t v_6;
      if (f1_0) {
         v_6 = *iname1_0;
      }
      else {
         v_6 = *iname2_0;
      }
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_6, &v_3, 0), _fx_cleanup);
      fx_str_t slit_0 = FX_MAKE_STR("variant \'");
      fx_str_t slit_1 = FX_MAKE_STR("\' claims to implement both \'");
      fx_str_t slit_2 = FX_MAKE_STR("\' and \'");
      fx_str_t slit_3 = FX_MAKE_STR("\', but one of them is the parent of another one; retain just \'");
      fx_str_t slit_4 = FX_MAKE_STR("\' in the list");
      {
         const fx_str_t strs_0[] = { slit_0, v_0, slit_1, v_1, slit_2, v_2, slit_3, v_3, slit_4 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_0, 9, &v_4), _fx_cleanup);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(dvar_loc_0, &v_4, &v_5, 0), _fx_cleanup);
      FX_THROW(&v_5, false, _fx_cleanup);
   }

_fx_cleanup: ;
   FX_FREE_STR(&v_0);
   FX_FREE_STR(&v_1);
   FX_FREE_STR(&v_2);
   FX_FREE_STR(&v_3);
   FX_FREE_STR(&v_4);
   fx_free_exn(&v_5);
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM17get_variant_casesT2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t2N10Ast__typ_tR10Ast__loc_t(
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t* fx_result,
   void* fx_fv)
{
   _fx_N10Ast__typ_t v_0 = 0;
   int fx_status = 0;
   FX_CALL(_fx_M3AstFM9deref_typN10Ast__typ_t1N10Ast__typ_t(t_0, &v_0, 0), _fx_cleanup);
   if (FX_REC_VARIANT_TAG(v_0) == 24) {
      _fx_N14Ast__id_info_t v_1 = {0};
      FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&v_0->u.TypApp.t1, loc_0, &v_1, 0), _fx_catch_0);
      if (v_1.tag == 6) {
         _fx_R17Ast__defvariant_t v_2 = {0};
         _fx_copy_R17Ast__defvariant_t(&v_1.u.IdVariant->data, &v_2);
         _fx_make_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(v_2.dvar_cases, v_2.dvar_ctors, fx_result);
         _fx_free_R17Ast__defvariant_t(&v_2);
      }
      else {
         _fx_make_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(0, 0, fx_result);
      }
      FX_CHECK_EXN(_fx_catch_0);

   _fx_catch_0: ;
      _fx_free_N14Ast__id_info_t(&v_1);
   }
   else {
      _fx_make_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(0, 0, fx_result);
   }

_fx_cleanup: ;
   if (v_0) {
      _fx_free_N10Ast__typ_t(&v_0);
   }
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
   struct _fx_N10Ast__pat_t_data_t* pat_0,
   struct _fx_N10Ast__typ_t_data_t* typ_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_Rt6Set__t1R9Ast__id_t* idset_0,
   struct _fx_Rt6Set__t1R9Ast__id_t* typ_vars_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool proto_mode_0,
   bool simple_pat_mode_0,
   bool is_mutable_0,
   struct _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB* fx_result,
   void* fx_fv)
{
   _fx_rRt6Set__t1R9Ast__id_t r_idset_ref_0 = 0;
   _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t r_env_ref_0 = 0;
   _fx_rRt6Set__t1R9Ast__id_t r_typ_vars_0 = 0;
   _fx_R16Ast__val_flags_t v_0 = {0};
   _fx_R16Ast__val_flags_t captured_val_flags_0 = {0};
   _fx_T2N10Ast__pat_tB v_1 = {0};
   _fx_N10Ast__pat_t pat_new_0 = 0;
   _fx_Rt6Set__t1R9Ast__id_t v_2 = {0};
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   FX_CALL(_fx_make_rRt6Set__t1R9Ast__id_t(idset_0, &r_idset_ref_0), _fx_cleanup);
   FX_CALL(_fx_make_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(env_0, &r_env_ref_0), _fx_cleanup);
   FX_CALL(_fx_make_rRt6Set__t1R9Ast__id_t(typ_vars_0, &r_typ_vars_0), _fx_cleanup);
   FX_CALL(_fx_M3AstFM17default_val_flagsRM11val_flags_t0(&v_0, 0), _fx_cleanup);
   _fx_make_R16Ast__val_flags_t(v_0.val_flag_arg, is_mutable_0, v_0.val_flag_temp, v_0.val_flag_tempref, v_0.val_flag_private,
      v_0.val_flag_subarray, v_0.val_flag_instance, &v_0.val_flag_method, v_0.val_flag_ctor, v_0.val_flag_global,
      &captured_val_flags_0);
   FX_CALL(
      _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
         pat_0, typ_0, &captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
         simple_pat_mode_0, &v_1, 0), _fx_cleanup);
   FX_COPY_PTR(v_1.t0, &pat_new_0);
   bool typed_0 = v_1.t1;
   _fx_copy_Rt6Set__t1R9Ast__id_t(&r_typ_vars_0->data, &v_2);
   _fx_make_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(pat_new_0,
      &r_env_ref_0->data, &r_idset_ref_0->data, &v_2, typed_0, fx_result);

_fx_cleanup: ;
   if (r_idset_ref_0) {
      _fx_free_rRt6Set__t1R9Ast__id_t(&r_idset_ref_0);
   }
   if (r_env_ref_0) {
      _fx_free_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&r_env_ref_0);
   }
   if (r_typ_vars_0) {
      _fx_free_rRt6Set__t1R9Ast__id_t(&r_typ_vars_0);
   }
   _fx_free_R16Ast__val_flags_t(&v_0);
   _fx_free_R16Ast__val_flags_t(&captured_val_flags_0);
   _fx_free_T2N10Ast__pat_tB(&v_1);
   if (pat_new_0) {
      _fx_free_N10Ast__pat_t(&pat_new_0);
   }
   _fx_free_Rt6Set__t1R9Ast__id_t(&v_2);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM10process_idR9Ast__id_t9R9Ast__id_tN10Ast__typ_tR10Ast__loc_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_tLN12Ast__scope_t(
   struct _fx_R9Ast__id_t* i0_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_R16Ast__val_flags_t* captured_val_flags_0,
   int_ curr_m_idx_0,
   bool proto_mode_0,
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* r_env_ref_0,
   struct _fx_rRt6Set__t1R9Ast__id_t_data_t* r_idset_ref_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R9Ast__id_t* fx_result,
   void* fx_fv)
{
   _fx_Nt11Set__tree_t1R9Ast__id_t v_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_1 = {0};
   _fx_Nt11Set__tree_t1R9Ast__id_t t_1 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t cmp_0 = {0};
   fx_str_t v_2 = {0};
   fx_str_t v_3 = {0};
   fx_exn_t v_4 = {0};
   _fx_Nt11Set__tree_t1R9Ast__id_t v_5 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_6 = {0};
   _fx_T2Nt11Set__tree_t1R9Ast__id_ti v_7 = {0};
   _fx_Nt11Set__tree_t1R9Ast__id_t t_2 = 0;
   _fx_T2Nt11Set__tree_t1R9Ast__id_tB v_8 = {0};
   _fx_Nt11Set__tree_t1R9Ast__id_t t_3 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_9 = {0};
   _fx_Rt6Set__t1R9Ast__id_t v_10 = {0};
   _fx_R13Ast__defval_t dv_0 = {0};
   _fx_N14Ast__id_info_t v_11 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_12 = {0};
   int fx_status = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* r_env_0 = &r_env_ref_0->data;
   _fx_Rt6Set__t1R9Ast__id_t* r_idset_0 = &r_idset_ref_0->data;
   FX_COPY_PTR(r_idset_0->root, &v_0);
   FX_COPY_FP(&r_idset_0->cmp, &v_1);
   bool result_0 = 0;
   FX_COPY_PTR(v_0, &t_1);
   _fx_R9Ast__id_t x_0 = *i0_0;
   FX_COPY_FP(&v_1, &cmp_0);
   for (;;) {
      _fx_Nt11Set__tree_t1R9Ast__id_t t_4 = 0;
      _fx_FPi2R9Ast__id_tR9Ast__id_t cmp_1 = {0};
      FX_COPY_PTR(t_1, &t_4);
      _fx_R9Ast__id_t x_1 = x_0;
      FX_COPY_FP(&cmp_0, &cmp_1);
      if ((t_4 != 0) + 1 == 2) {
         _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_0 = &t_4->u.Node;
         int_ c_0;
         FX_CALL(cmp_1.fp(&x_1, &vcase_0->t2, &c_0, cmp_1.fcv), _fx_catch_0);
         if (c_0 < 0) {
            _fx_Nt11Set__tree_t1R9Ast__id_t* l_0 = &vcase_0->t1;
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_1);
            FX_COPY_PTR(*l_0, &t_1);
            x_0 = x_1;
            FX_FREE_FP(&cmp_0);
            FX_COPY_FP(&cmp_1, &cmp_0);
         }
         else if (c_0 > 0) {
            _fx_Nt11Set__tree_t1R9Ast__id_t* r_0 = &vcase_0->t3;
            _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_1);
            FX_COPY_PTR(*r_0, &t_1);
            x_0 = x_1;
            FX_FREE_FP(&cmp_0);
            FX_COPY_FP(&cmp_1, &cmp_0);
         }
         else {
            result_0 = true; FX_BREAK(_fx_catch_0);
         }

      _fx_catch_0: ;
      }
      else {
         result_0 = false; FX_BREAK(_fx_catch_1);  _fx_catch_1: ;
      }
      FX_CHECK_EXN(_fx_catch_2);

   _fx_catch_2: ;
      FX_FREE_FP(&cmp_1);
      if (t_4) {
         _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_4);
      }
      FX_CHECK_BREAK();
      FX_CHECK_EXN(_fx_cleanup);
   }
   if (result_0) {
      FX_CALL(_fx_M3AstFM6stringS1RM4id_t(i0_0, &v_2, 0), _fx_cleanup);
      fx_str_t slit_0 = FX_MAKE_STR("duplicate identifier \'");
      fx_str_t slit_1 = FX_MAKE_STR("\' in the pattern");
      {
         const fx_str_t strs_0[] = { slit_0, v_2, slit_1 };
         FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &v_3), _fx_cleanup);
      }
      FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &v_3, &v_4, 0), _fx_cleanup);
      FX_THROW(&v_4, false, _fx_cleanup);
   }
   else {
      FX_COPY_PTR(r_idset_0->root, &v_5);
      FX_COPY_FP(&r_idset_0->cmp, &v_6);
      FX_CALL(
         _fx_M13Ast_typecheckFM12add_to_tree_T2Nt11Set__tree_t1R9Ast__id_ti3Nt11Set__tree_t1R9Ast__id_tR9Ast__id_tFPi2R9Ast__id_tR9Ast__id_t(
            v_5, i0_0, &v_6, &v_7, 0), _fx_cleanup);
      FX_COPY_PTR(v_7.t0, &t_2);
      int_ dsz_0 = v_7.t1;
      if ((t_2 != 0) + 1 == 2) {
         _fx_T4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t* vcase_1 = &t_2->u.Node;
         if (vcase_1->t0.tag == 1) {
            _fx_Nt11Set__tree_t1R9Ast__id_t v_13 = 0;
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Set__tree_t1R9Ast__id_t4N12Set__color_tNt11Set__tree_t1R9Ast__id_tR9Ast__id_tNt11Set__tree_t1R9Ast__id_t(
                  &_fx_g22Ast_typecheck__Black1_, vcase_1->t1, &vcase_1->t2, vcase_1->t3, &v_13), _fx_catch_3);
            _fx_make_T2Nt11Set__tree_t1R9Ast__id_tB(v_13, false, &v_8);

         _fx_catch_3: ;
            if (v_13) {
               _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_13);
            }
            goto _fx_endmatch_0;
         }
      }
      _fx_make_T2Nt11Set__tree_t1R9Ast__id_tB(t_2, true, &v_8);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_cleanup);
      FX_COPY_PTR(v_8.t0, &t_3);
      FX_COPY_FP(&r_idset_0->cmp, &v_9);
      _fx_make_Rt6Set__t1R9Ast__id_t(t_3, r_idset_0->size + dsz_0, &v_9, &v_10);
      _fx_free_Rt6Set__t1R9Ast__id_t(r_idset_0);
      _fx_copy_Rt6Set__t1R9Ast__id_t(&v_10, r_idset_0);
   }
   if (proto_mode_0) {
      *fx_result = *i0_0;
   }
   else {
      _fx_R9Ast__id_t j_0;
      FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(curr_m_idx_0, i0_0, &j_0, 0), _fx_cleanup);
      _fx_make_R13Ast__defval_t(&j_0, t_0, captured_val_flags_0, sc_0, loc_0, &dv_0);
      _fx_M3AstFM6IdDValN14Ast__id_info_t1RM8defval_t(&dv_0, &v_11);
      FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&j_0, &v_11, 0), _fx_cleanup);
      FX_CALL(
         _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
            i0_0, &j_0, r_env_0, &v_12, 0), _fx_cleanup);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(r_env_0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_12, r_env_0);
      *fx_result = j_0;
   }

_fx_cleanup: ;
   if (v_0) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_0);
   }
   FX_FREE_FP(&v_1);
   if (t_1) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_1);
   }
   FX_FREE_FP(&cmp_0);
   FX_FREE_STR(&v_2);
   FX_FREE_STR(&v_3);
   fx_free_exn(&v_4);
   if (v_5) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&v_5);
   }
   FX_FREE_FP(&v_6);
   _fx_free_T2Nt11Set__tree_t1R9Ast__id_ti(&v_7);
   if (t_2) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_2);
   }
   _fx_free_T2Nt11Set__tree_t1R9Ast__id_tB(&v_8);
   if (t_3) {
      _fx_free_Nt11Set__tree_t1R9Ast__id_t(&t_3);
   }
   FX_FREE_FP(&v_9);
   _fx_free_Rt6Set__t1R9Ast__id_t(&v_10);
   _fx_free_R13Ast__defval_t(&dv_0);
   _fx_free_N14Ast__id_info_t(&v_11);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_12);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
   struct _fx_N10Ast__pat_t_data_t* p_0,
   struct _fx_N10Ast__typ_t_data_t* t_0,
   struct _fx_R16Ast__val_flags_t* captured_val_flags_0,
   int_ curr_m_idx_0,
   bool proto_mode_0,
   struct _fx_rRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_data_t* r_env_ref_0,
   struct _fx_rRt6Set__t1R9Ast__id_t_data_t* r_idset_ref_0,
   struct _fx_rRt6Set__t1R9Ast__id_t_data_t* r_typ_vars_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   bool simple_pat_mode_0,
   struct _fx_T2N10Ast__pat_tB* fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* r_env_0 = &r_env_ref_0->data;
   int tag_0 = FX_REC_VARIANT_TAG(p_0);
   if (tag_0 == 1) {
      _fx_make_T2N10Ast__pat_tB(p_0, false, fx_result);
   }
   else if (tag_0 == 2) {
      fx_exn_t v_0 = {0};
      _fx_N10Ast__typ_t v_1 = 0;
      _fx_T2N10Ast__lit_tR10Ast__loc_t* vcase_0 = &p_0->u.PatLit;
      _fx_R10Ast__loc_t* loc_0 = &vcase_0->t1;
      _fx_N10Ast__lit_t* l_0 = &vcase_0->t0;
      if (simple_pat_mode_0) {
         fx_str_t slit_0 = FX_MAKE_STR("literals are not allowed here");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_0, &slit_0, &v_0, 0), _fx_catch_0);
         FX_THROW(&v_0, false, _fx_catch_0);
      }
      FX_CALL(_fx_M3AstFM11get_lit_typN10Ast__typ_t1N10Ast__lit_t(l_0, &v_1, 0), _fx_catch_0);
      fx_str_t slit_1 = FX_MAKE_STR("the literal of unexpected type");
      FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t_0, v_1, loc_0, &slit_1, 0), _fx_catch_0);
      bool res_0;
      if (l_0->tag == 8) {
         res_0 = false;
      }
      else {
         res_0 = true;
      }
      FX_CHECK_EXN(_fx_catch_0);
      _fx_make_T2N10Ast__pat_tB(p_0, res_0, fx_result);

   _fx_catch_0: ;
      if (v_1) {
         _fx_free_N10Ast__typ_t(&v_1);
      }
      fx_free_exn(&v_0);
   }
   else if (tag_0 == 3) {
      fx_str_t v_2 = {0};
      fx_exn_t v_3 = {0};
      _fx_N10Ast__pat_t v_4 = 0;
      _fx_T2R9Ast__id_tR10Ast__loc_t* vcase_1 = &p_0->u.PatIdent;
      _fx_R10Ast__loc_t* loc_1 = &vcase_1->t1;
      _fx_R9Ast__id_t* i_0 = &vcase_1->t0;
      FX_CALL(_fx_M3AstFM2ppS1RM4id_t(i_0, &v_2, 0), _fx_catch_1);
      bool v_5;
      fx_str_t slit_2 = FX_MAKE_STR("_");
      v_5 = _fx_F6__eq__B2SS(&v_2, &slit_2, 0);
      if (v_5) {
         fx_str_t slit_3 = FX_MAKE_STR("\'_\' occured in PatIdent()");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_1, &slit_3, &v_3, 0), _fx_catch_1);
         FX_THROW(&v_3, false, _fx_catch_1);
      }
      _fx_R9Ast__id_t v_6;
      FX_CALL(
         _fx_M13Ast_typecheckFM10process_idR9Ast__id_t9R9Ast__id_tN10Ast__typ_tR10Ast__loc_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_tLN12Ast__scope_t(
            i_0, t_0, loc_1, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, sc_0, &v_6, 0),
         _fx_catch_1);
      FX_CALL(_fx_M3AstFM8PatIdentN10Ast__pat_t2RM4id_tRM5loc_t(&v_6, loc_1, &v_4), _fx_catch_1);
      _fx_make_T2N10Ast__pat_tB(v_4, false, fx_result);

   _fx_catch_1: ;
      if (v_4) {
         _fx_free_N10Ast__pat_t(&v_4);
      }
      fx_free_exn(&v_3);
      FX_FREE_STR(&v_2);
   }
   else if (tag_0 == 4) {
      _fx_LN10Ast__typ_t tl_0 = 0;
      _fx_LN10Ast__pat_t pl_0 = 0;
      _fx_N10Ast__typ_t v_7 = 0;
      _fx_LN10Ast__pat_t pl_new_0 = 0;
      _fx_LN10Ast__pat_t pl_1 = 0;
      _fx_N10Ast__pat_t v_8 = 0;
      _fx_T2LN10Ast__pat_tR10Ast__loc_t* vcase_2 = &p_0->u.PatTuple;
      _fx_R10Ast__loc_t* loc_2 = &vcase_2->t1;
      _fx_LN10Ast__pat_t pl_2 = vcase_2->t0;
      _fx_LN10Ast__typ_t lstend_0 = 0;
      FX_COPY_PTR(pl_2, &pl_0);
      _fx_LN10Ast__pat_t lst_0 = pl_0;
      for (; lst_0; lst_0 = lst_0->tl) {
         _fx_N10Ast__typ_t res_1 = 0;
         _fx_N10Ast__pat_t p_1 = lst_0->hd;
         FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&res_1, 0), _fx_catch_2);
         _fx_LN10Ast__typ_t node_0 = 0;
         FX_CALL(_fx_cons_LN10Ast__typ_t(res_1, 0, false, &node_0), _fx_catch_2);
         FX_LIST_APPEND(tl_0, lstend_0, node_0);

      _fx_catch_2: ;
         if (res_1) {
            _fx_free_N10Ast__typ_t(&res_1);
         }
         FX_CHECK_EXN(_fx_catch_4);
      }
      FX_CALL(_fx_M3AstFM8TypTupleN10Ast__typ_t1LN10Ast__typ_t(tl_0, &v_7), _fx_catch_4);
      fx_str_t slit_4 = FX_MAKE_STR("improper type of the tuple pattern");
      FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t_0, v_7, loc_2, &slit_4, 0), _fx_catch_4);
      bool typed_0 = true;
      _fx_LN10Ast__pat_t lstend_1 = 0;
      FX_COPY_PTR(pl_2, &pl_1);
      _fx_LN10Ast__pat_t lst_1 = pl_1;
      _fx_LN10Ast__typ_t lst_2 = tl_0;
      for (; lst_1 && lst_2; lst_2 = lst_2->tl, lst_1 = lst_1->tl) {
         _fx_T2N10Ast__pat_tB v_9 = {0};
         _fx_N10Ast__pat_t pj_0 = 0;
         _fx_N10Ast__typ_t t_1 = lst_2->hd;
         _fx_N10Ast__pat_t p_2 = lst_1->hd;
         FX_CALL(
            _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
               p_2, t_1, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
               simple_pat_mode_0, &v_9, 0), _fx_catch_3);
         FX_COPY_PTR(v_9.t0, &pj_0);
         bool typed_j_0 = v_9.t1;
         typed_0 = (bool)(typed_0 & typed_j_0);
         _fx_LN10Ast__pat_t node_1 = 0;
         FX_CALL(_fx_cons_LN10Ast__pat_t(pj_0, 0, false, &node_1), _fx_catch_3);
         FX_LIST_APPEND(pl_new_0, lstend_1, node_1);

      _fx_catch_3: ;
         if (pj_0) {
            _fx_free_N10Ast__pat_t(&pj_0);
         }
         _fx_free_T2N10Ast__pat_tB(&v_9);
         FX_CHECK_EXN(_fx_catch_4);
      }
      int s_0 = !lst_1 + !lst_2;
      FX_CHECK_EQ_SIZE(s_0 == 0 || s_0 == 2, _fx_catch_4);
      FX_CALL(_fx_M3AstFM8PatTupleN10Ast__pat_t2LN10Ast__pat_tRM5loc_t(pl_new_0, loc_2, &v_8), _fx_catch_4);
      _fx_make_T2N10Ast__pat_tB(v_8, typed_0, fx_result);

   _fx_catch_4: ;
      if (v_8) {
         _fx_free_N10Ast__pat_t(&v_8);
      }
      if (pl_1) {
         _fx_free_LN10Ast__pat_t(&pl_1);
      }
      if (pl_new_0) {
         _fx_free_LN10Ast__pat_t(&pl_new_0);
      }
      if (v_7) {
         _fx_free_N10Ast__typ_t(&v_7);
      }
      if (pl_0) {
         _fx_free_LN10Ast__pat_t(&pl_0);
      }
      if (tl_0) {
         _fx_free_LN10Ast__typ_t(&tl_0);
      }
   }
   else if (tag_0 == 5) {
      _fx_LN10Ast__pat_t pl_3 = 0;
      _fx_LN10Ast__typ_t tl_1 = 0;
      _fx_N10Ast__typ_t ctyp_0 = 0;
      _fx_T2R9Ast__id_tN10Ast__typ_t v_10 = {0};
      _fx_LN10Ast__pat_t v_11 = 0;
      _fx_N10Ast__pat_t v_12 = 0;
      _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t v_13 = {0};
      _fx_LT2R9Ast__id_tN10Ast__typ_t v_14 = 0;
      _fx_T3R9Ast__id_tLN10Ast__pat_tR10Ast__loc_t* vcase_3 = &p_0->u.PatVariant;
      _fx_R10Ast__loc_t* loc_3 = &vcase_3->t2;
      _fx_LN10Ast__pat_t pl_4 = vcase_3->t1;
      _fx_R9Ast__id_t* v_15 = &vcase_3->t0;
      _fx_R9Ast__id_t bare_v_0;
      FX_CALL(_fx_M3AstFM13get_bare_nameRM4id_t1RM4id_t(v_15, &bare_v_0, 0), _fx_catch_18);
      if (!proto_mode_0) {
         if (pl_4 != 0) {
            if (pl_4->tl == 0) {
               _fx_N10Ast__pat_t v_16 = pl_4->hd;
               if (FX_REC_VARIANT_TAG(v_16) == 1) {
                  _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t __fold_result___0 = {0};
                  _fx_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t v_17 = {0};
                  _fx_LT2R9Ast__id_tN10Ast__typ_t v_18 = 0;
                  _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t __fold_result___1 = {0};
                  _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&_fx_g21Ast_typecheck__None6_, &__fold_result___0);
                  FX_CALL(
                     _fx_M13Ast_typecheckFM17get_variant_casesT2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t2N10Ast__typ_tR10Ast__loc_t(
                        t_0, loc_3, &v_17, 0), _fx_catch_9);
                  FX_COPY_PTR(v_17.t0, &v_18);
                  _fx_LT2R9Ast__id_tN10Ast__typ_t lst_3 = v_18;
                  for (; lst_3; lst_3 = lst_3->tl) {
                     _fx_Nt6option1T2R9Ast__id_tN10Ast__typ_t v_19 = {0};
                     _fx_T2R9Ast__id_tN10Ast__typ_t* __pat___0 = &lst_3->hd;
                     _fx_R9Ast__id_t n_0 = __pat___0->t0;
                     _fx_R9Ast__id_t v_20;
                     FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&n_0, &v_20, 0), _fx_catch_5);
                     bool res_2;
                     FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_20, &bare_v_0, &res_2, 0), _fx_catch_5);
                     if (res_2) {
                        _fx_M13Ast_typecheckFM4SomeNt6option1T2R9Ast__id_tN10Ast__typ_t1T2R9Ast__id_tN10Ast__typ_t(__pat___0,
                           &v_19);
                        _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&__fold_result___0);
                        _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_19, &__fold_result___0);
                        FX_BREAK(_fx_catch_5);
                     }

                  _fx_catch_5: ;
                     _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&v_19);
                     FX_CHECK_BREAK();
                     FX_CHECK_EXN(_fx_catch_9);
                  }
                  _fx_copy_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&__fold_result___0, &__fold_result___1);
                  if (__fold_result___1.tag == 2) {
                     _fx_N10Ast__typ_t t_2 = __fold_result___1.u.Some.t1;
                     int tag_1 = FX_REC_VARIANT_TAG(t_2);
                     if (tag_1 == 17) {
                        _fx_LN10Ast__typ_t tl_2 = 0;
                        _fx_LN10Ast__pat_t lstend_2 = 0;
                        FX_COPY_PTR(t_2->u.TypTuple, &tl_2);
                        _fx_LN10Ast__typ_t lst_4 = tl_2;
                        for (; lst_4; lst_4 = lst_4->tl) {
                           _fx_N10Ast__pat_t res_3 = 0;
                           _fx_N10Ast__typ_t __pat___1 = lst_4->hd;
                           FX_CALL(_fx_M3AstFM6PatAnyN10Ast__pat_t1RM5loc_t(&v_16->u.PatAny, &res_3), _fx_catch_6);
                           _fx_LN10Ast__pat_t node_2 = 0;
                           FX_CALL(_fx_cons_LN10Ast__pat_t(res_3, 0, false, &node_2), _fx_catch_6);
                           FX_LIST_APPEND(pl_3, lstend_2, node_2);

                        _fx_catch_6: ;
                           if (res_3) {
                              _fx_free_N10Ast__pat_t(&res_3);
                           }
                           FX_CHECK_EXN(_fx_catch_7);
                        }

                     _fx_catch_7: ;
                        if (tl_2) {
                           _fx_free_LN10Ast__typ_t(&tl_2);
                        }
                     }
                     else if (tag_1 != 13) {
                        FX_COPY_PTR(pl_4, &pl_3);
                     }
                     FX_CHECK_EXN(_fx_catch_8);

                  _fx_catch_8: ;
                  }
                  else {
                     FX_COPY_PTR(pl_4, &pl_3);
                  }
                  FX_CHECK_EXN(_fx_catch_9);

               _fx_catch_9: ;
                  _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&__fold_result___1);
                  if (v_18) {
                     _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&v_18);
                  }
                  _fx_free_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(&v_17);
                  _fx_free_Nt6option1T2R9Ast__id_tN10Ast__typ_t(&__fold_result___0);
                  goto _fx_endmatch_0;
               }
            }
         }
         FX_COPY_PTR(pl_4, &pl_3);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_18);
         _fx_LN10Ast__typ_t lstend_3 = 0;
         _fx_LN10Ast__pat_t lst_5 = pl_3;
         for (; lst_5; lst_5 = lst_5->tl) {
            _fx_N10Ast__typ_t res_4 = 0;
            _fx_N10Ast__pat_t p_3 = lst_5->hd;
            FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&res_4, 0), _fx_catch_10);
            _fx_LN10Ast__typ_t node_3 = 0;
            FX_CALL(_fx_cons_LN10Ast__typ_t(res_4, 0, false, &node_3), _fx_catch_10);
            FX_LIST_APPEND(tl_1, lstend_3, node_3);

         _fx_catch_10: ;
            if (res_4) {
               _fx_free_N10Ast__typ_t(&res_4);
            }
            FX_CHECK_EXN(_fx_catch_18);
         }
         if (tl_1 == 0) {
            FX_COPY_PTR(t_0, &ctyp_0);
         }
         else {
            FX_CALL(_fx_M3AstFM6TypFunN10Ast__typ_t2LN10Ast__typ_tN10Ast__typ_t(tl_1, t_0, &ctyp_0), _fx_catch_11);

         _fx_catch_11: ;
         }
         FX_CHECK_EXN(_fx_catch_18);
         FX_CALL(
            _fx_M13Ast_typecheckFM9lookup_idT2R9Ast__id_tN10Ast__typ_t5R9Ast__id_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
               v_15, ctyp_0, r_env_0, sc_0, loc_3, &v_10, 0), _fx_catch_18);
         _fx_R9Ast__id_t v_new_0 = v_10.t0;
         _fx_LN10Ast__pat_t lstend_4 = 0;
         _fx_LN10Ast__pat_t lst_6 = pl_3;
         _fx_LN10Ast__typ_t lst_7 = tl_1;
         for (; lst_6 && lst_7; lst_7 = lst_7->tl, lst_6 = lst_6->tl) {
            _fx_T2N10Ast__pat_tB v_21 = {0};
            _fx_N10Ast__typ_t t_3 = lst_7->hd;
            _fx_N10Ast__pat_t p_4 = lst_6->hd;
            FX_CALL(
               _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
                  p_4, t_3, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
                  simple_pat_mode_0, &v_21, 0), _fx_catch_12);
            _fx_LN10Ast__pat_t node_4 = 0;
            FX_CALL(_fx_cons_LN10Ast__pat_t(v_21.t0, 0, false, &node_4), _fx_catch_12);
            FX_LIST_APPEND(v_11, lstend_4, node_4);

         _fx_catch_12: ;
            _fx_free_T2N10Ast__pat_tB(&v_21);
            FX_CHECK_EXN(_fx_catch_18);
         }
         int s_1 = !lst_6 + !lst_7;
         FX_CHECK_EQ_SIZE(s_1 == 0 || s_1 == 2, _fx_catch_18);
         FX_CALL(_fx_M3AstFM10PatVariantN10Ast__pat_t3RM4id_tLN10Ast__pat_tRM5loc_t(&v_new_0, v_11, loc_3, &v_12),
            _fx_catch_18);
         _fx_make_T2N10Ast__pat_tB(v_12, false, fx_result);
      }
      else {
         FX_CALL(
            _fx_M13Ast_typecheckFM17get_variant_casesT2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t2N10Ast__typ_tR10Ast__loc_t(t_0,
               loc_3, &v_13, 0), _fx_catch_18);
         FX_COPY_PTR(v_13.t0, &v_14);
         if (v_14 == 0) {
            fx_exn_t v_22 = {0};
            fx_str_t slit_5 = FX_MAKE_STR("variant pattern is used with non-variant type");
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_3, &slit_5, &v_22, 0), _fx_catch_13);
            FX_THROW(&v_22, false, _fx_catch_13);

         _fx_catch_13: ;
            fx_free_exn(&v_22);
         }
         else {
            fx_exn_t v_23 = {0};
            _fx_Nt6option1N10Ast__typ_t v_24 = 0;
            fx_str_t v_25 = {0};
            fx_str_t v_26 = {0};
            fx_str_t v_27 = {0};
            fx_exn_t v_28 = {0};
            _fx_N10Ast__pat_t v_29 = 0;
            int_ v_30;
            FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LT2R9Ast__id_tN10Ast__typ_t(v_14, &v_30, 0), _fx_catch_17);
            if (v_30 != 1) {
               fx_str_t slit_6 = FX_MAKE_STR("a label of multi-case variant may not be used in a formal function parameter");
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_3, &slit_6, &v_23, 0), _fx_catch_17);
               FX_THROW(&v_23, false, _fx_catch_17);
            }
            else {
               FX_CALL(
                  _fx_M13Ast_typecheckFM9assoc_optNt6option1N10Ast__typ_t2LT2R9Ast__id_tN10Ast__typ_tR9Ast__id_t(v_14,
                     &bare_v_0, &v_24, 0), _fx_catch_17);
               int tag_2 = (v_24 != 0) + 1;
               int_ ni_0;
               if (tag_2 == 2) {
                  _fx_N10Ast__typ_t v_31 = v_24->u.Some;
                  if (FX_REC_VARIANT_TAG(v_31) == 17) {
                     FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__typ_t(v_31->u.TypTuple, &ni_0, 0), _fx_catch_14);

                  _fx_catch_14: ;
                     goto _fx_endmatch_1;
                  }
               }
               if (tag_2 == 2) {
                  if (FX_REC_VARIANT_TAG(v_24->u.Some) == 13) {
                     fx_str_t v_32 = {0};
                     fx_str_t v_33 = {0};
                     fx_str_t v_34 = {0};
                     fx_exn_t v_35 = {0};
                     FX_CALL(_fx_M3AstFM2ppS1RM4id_t(v_15, &v_32, 0), _fx_catch_15);
                     FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_32, &v_33, 0), _fx_catch_15);
                     fx_str_t slit_7 = FX_MAKE_STR("a variant label \'");
                     fx_str_t slit_8 = FX_MAKE_STR("\' with no arguments may not be used in a formal function parameter");
                     {
                        const fx_str_t strs_0[] = { slit_7, v_33, slit_8 };
                        FX_CALL(fx_strjoin(0, 0, 0, strs_0, 3, &v_34), _fx_catch_15);
                     }
                     FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_3, &v_34, &v_35, 0), _fx_catch_15);
                     FX_THROW(&v_35, false, _fx_catch_15);

                  _fx_catch_15: ;
                     fx_free_exn(&v_35);
                     FX_FREE_STR(&v_34);
                     FX_FREE_STR(&v_33);
                     FX_FREE_STR(&v_32);
                     goto _fx_endmatch_1;
                  }
               }
               if (tag_2 == 2) {
                  ni_0 = 1; goto _fx_endmatch_1;
               }
               fx_str_t v_36 = {0};
               fx_str_t v_37 = {0};
               fx_str_t v_38 = {0};
               fx_exn_t v_39 = {0};
               FX_CALL(_fx_M3AstFM2ppS1RM4id_t(v_15, &v_36, 0), _fx_catch_16);
               FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_36, &v_37, 0), _fx_catch_16);
               fx_str_t slit_9 = FX_MAKE_STR("the variant constructor \'");
               fx_str_t slit_10 = FX_MAKE_STR("\' is not found");
               {
                  const fx_str_t strs_1[] = { slit_9, v_37, slit_10 };
                  FX_CALL(fx_strjoin(0, 0, 0, strs_1, 3, &v_38), _fx_catch_16);
               }
               FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_3, &v_38, &v_39, 0), _fx_catch_16);
               FX_THROW(&v_39, false, _fx_catch_16);

            _fx_catch_16: ;
               fx_free_exn(&v_39);
               FX_FREE_STR(&v_38);
               FX_FREE_STR(&v_37);
               FX_FREE_STR(&v_36);

            _fx_endmatch_1: ;
               FX_CHECK_EXN(_fx_catch_17);
               int_ v_40;
               FX_CALL(_fx_M13Ast_typecheckFM8length1_i1LN10Ast__pat_t(pl_4, &v_40, 0), _fx_catch_17);
               if (ni_0 != v_40) {
                  FX_CALL(_fx_M3AstFM2ppS1RM4id_t(v_15, &v_25, 0), _fx_catch_17);
                  FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_25, &v_26, 0), _fx_catch_17);
                  fx_str_t slit_11 =
                     FX_MAKE_STR(
                        "the number of variant pattern arguments does not match to the description of variant case \'");
                  fx_str_t slit_12 = FX_MAKE_STR("\'");
                  {
                     const fx_str_t strs_2[] = { slit_11, v_26, slit_12 };
                     FX_CALL(fx_strjoin(0, 0, 0, strs_2, 3, &v_27), _fx_catch_17);
                  }
                  FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_3, &v_27, &v_28, 0), _fx_catch_17);
                  FX_THROW(&v_28, false, _fx_catch_17);
               }
               FX_CALL(_fx_M3AstFM10PatVariantN10Ast__pat_t3RM4id_tLN10Ast__pat_tRM5loc_t(v_15, pl_4, loc_3, &v_29),
                  _fx_catch_17);
               _fx_make_T2N10Ast__pat_tB(v_29, false, fx_result);
            }

         _fx_catch_17: ;
            if (v_29) {
               _fx_free_N10Ast__pat_t(&v_29);
            }
            fx_free_exn(&v_28);
            FX_FREE_STR(&v_27);
            FX_FREE_STR(&v_26);
            FX_FREE_STR(&v_25);
            if (v_24) {
               _fx_free_Nt6option1N10Ast__typ_t(&v_24);
            }
            fx_free_exn(&v_23);
         }
         FX_CHECK_EXN(_fx_catch_18);
      }

   _fx_catch_18: ;
      if (v_14) {
         _fx_free_LT2R9Ast__id_tN10Ast__typ_t(&v_14);
      }
      _fx_free_T2LT2R9Ast__id_tN10Ast__typ_tLR9Ast__id_t(&v_13);
      if (v_12) {
         _fx_free_N10Ast__pat_t(&v_12);
      }
      if (v_11) {
         _fx_free_LN10Ast__pat_t(&v_11);
      }
      _fx_free_T2R9Ast__id_tN10Ast__typ_t(&v_10);
      if (ctyp_0) {
         _fx_free_N10Ast__typ_t(&ctyp_0);
      }
      if (tl_1) {
         _fx_free_LN10Ast__typ_t(&tl_1);
      }
      if (pl_3) {
         _fx_free_LN10Ast__pat_t(&pl_3);
      }
   }
   else if (tag_0 == 6) {
      fx_exn_t exn_0 = {0};
      _fx_T3Nt6option1R9Ast__id_tLT2R9Ast__id_tN10Ast__pat_tR10Ast__loc_t* vcase_4 = &p_0->u.PatRecord;
      _fx_R10Ast__loc_t* loc_4 = &vcase_4->t2;
      _fx_LT2R9Ast__id_tN10Ast__pat_t relems_0 = vcase_4->t1;
      _fx_Nt6option1R9Ast__id_t* rn_opt_0 = &vcase_4->t0;
      _fx_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_41 = {0};
      _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t relems_found_0 = 0;
      _fx_LT2R9Ast__id_tN10Ast__pat_t new_relems_0 = 0;
      _fx_LT2R9Ast__id_tN10Ast__pat_t relems_1 = 0;
      _fx_N10Ast__pat_t v_42 = 0;
      FX_CALL(
         _fx_M13Ast_typecheckFM16get_record_elemsT2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t4Nt6option1R9Ast__id_tN10Ast__typ_tBR10Ast__loc_t(
            rn_opt_0, t_0, proto_mode_0, loc_4, &v_41, 0), _fx_catch_23);
      _fx_R9Ast__id_t ctor_0 = v_41.t0;
      FX_COPY_PTR(v_41.t1, &relems_found_0);
      _fx_LT2R9Ast__id_tN10Ast__pat_t lstend_5 = 0;
      FX_COPY_PTR(relems_0, &relems_1);
      _fx_LT2R9Ast__id_tN10Ast__pat_t lst_8 = relems_1;
      for (; lst_8; lst_8 = lst_8->tl) {
         _fx_N10Ast__pat_t p_5 = 0;
         _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t __fold_result___2 = {0};
         _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t __fold_result___3 = {0};
         _fx_T2R9Ast__id_tN10Ast__pat_t res_5 = {0};
         _fx_T2R9Ast__id_tN10Ast__pat_t* __pat___2 = &lst_8->hd;
         _fx_R9Ast__id_t n_1 = __pat___2->t0;
         FX_COPY_PTR(__pat___2->t1, &p_5);
         _fx_R9Ast__id_t n_orig_0;
         FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&n_1, &n_orig_0, 0), _fx_catch_22);
         _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&_fx_g21Ast_typecheck__None1_,
            &__fold_result___2);
         _fx_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t lst_9 = relems_found_0;
         for (; lst_9; lst_9 = lst_9->tl) {
            _fx_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t v_43 = {0};
            _fx_T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t* __pat___3 = &lst_9->hd;
            _fx_R9Ast__id_t nj_0 = __pat___3->t1;
            _fx_R9Ast__id_t v_44;
            FX_CALL(_fx_M3AstFM11get_orig_idRM4id_t1RM4id_t(&nj_0, &v_44, 0), _fx_catch_19);
            bool res_6;
            FX_CALL(_fx_M3AstFM6__eq__B2RM4id_tRM4id_t(&v_44, &n_orig_0, &res_6, 0), _fx_catch_19);
            if (res_6) {
               _fx_M13Ast_typecheckFM4SomeNt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(
                  __pat___3, &v_43);
               _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___2);
               _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_43, &__fold_result___2);
               FX_BREAK(_fx_catch_19);
            }

         _fx_catch_19: ;
            _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_43);
            FX_CHECK_BREAK();
            FX_CHECK_EXN(_fx_catch_22);
         }
         _fx_copy_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___2, &__fold_result___3);
         if (__fold_result___3.tag == 2) {
            _fx_T2N10Ast__pat_tB v_45 = {0};
            _fx_N10Ast__pat_t p_6 = 0;
            if (proto_mode_0) {
               _fx_make_T2N10Ast__pat_tB(p_5, false, &v_45);
            }
            else {
               FX_CALL(
                  _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
                     p_5, __fold_result___3.u.Some.t2, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0,
                     r_idset_ref_0, r_typ_vars_0, sc_0, simple_pat_mode_0, &v_45, 0), _fx_catch_20);
            }
            FX_COPY_PTR(v_45.t0, &p_6);
            _fx_make_T2R9Ast__id_tN10Ast__pat_t(&n_1, p_6, &res_5);

         _fx_catch_20: ;
            if (p_6) {
               _fx_free_N10Ast__pat_t(&p_6);
            }
            _fx_free_T2N10Ast__pat_tB(&v_45);
         }
         else {
            fx_str_t v_46 = {0};
            fx_str_t v_47 = {0};
            fx_str_t v_48 = {0};
            fx_str_t v_49 = {0};
            fx_str_t v_50 = {0};
            fx_exn_t v_51 = {0};
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&n_1, &v_46, 0), _fx_catch_21);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_46, &v_47, 0), _fx_catch_21);
            _fx_R9Ast__id_t v_52;
            FX_CALL(
               _fx_M13Ast_typecheckFM8value_orR9Ast__id_t2Nt6option1R9Ast__id_tR9Ast__id_t(rn_opt_0, &_fx_g9Ast__noid, &v_52,
                  0), _fx_catch_21);
            FX_CALL(_fx_M3AstFM2ppS1RM4id_t(&v_52, &v_48, 0), _fx_catch_21);
            FX_CALL(_fx_M13Ast_typecheckFM6stringS1S(&v_48, &v_49, 0), _fx_catch_21);
            fx_str_t slit_13 = FX_MAKE_STR("element \'");
            fx_str_t slit_14 = FX_MAKE_STR("\' is not found in the record \'");
            fx_str_t slit_15 = FX_MAKE_STR("\'");
            {
               const fx_str_t strs_3[] = { slit_13, v_47, slit_14, v_49, slit_15 };
               FX_CALL(fx_strjoin(0, 0, 0, strs_3, 5, &v_50), _fx_catch_21);
            }
            FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_4, &v_50, &v_51, 0), _fx_catch_21);
            FX_THROW(&v_51, false, _fx_catch_21);

         _fx_catch_21: ;
            fx_free_exn(&v_51);
            FX_FREE_STR(&v_50);
            FX_FREE_STR(&v_49);
            FX_FREE_STR(&v_48);
            FX_FREE_STR(&v_47);
            FX_FREE_STR(&v_46);
         }
         FX_CHECK_EXN(_fx_catch_22);
         _fx_LT2R9Ast__id_tN10Ast__pat_t node_5 = 0;
         FX_CALL(_fx_cons_LT2R9Ast__id_tN10Ast__pat_t(&res_5, 0, false, &node_5), _fx_catch_22);
         FX_LIST_APPEND(new_relems_0, lstend_5, node_5);

      _fx_catch_22: ;
         _fx_free_T2R9Ast__id_tN10Ast__pat_t(&res_5);
         _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___3);
         _fx_free_Nt6option1T4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&__fold_result___2);
         if (p_5) {
            _fx_free_N10Ast__pat_t(&p_5);
         }
         FX_CHECK_EXN(_fx_catch_23);
      }
      bool res_7;
      FX_CALL(_fx_M13Ast_typecheckFM6__ne__B2R9Ast__id_tR9Ast__id_t(&ctor_0, &_fx_g9Ast__noid, &res_7, 0), _fx_catch_23);
      _fx_Nt6option1R9Ast__id_t v_53;
      if (res_7) {
         _fx_M13Ast_typecheckFM4SomeNt6option1R9Ast__id_t1R9Ast__id_t(&ctor_0, &v_53);
      }
      else {
         v_53 = _fx_g21Ast_typecheck__None9_;
      }
      FX_CALL(
         _fx_M3AstFM9PatRecordN10Ast__pat_t3Nt6option1RM4id_tLT2RM4id_tN10Ast__pat_tRM5loc_t(&v_53, new_relems_0, loc_4, &v_42),
         _fx_catch_23);
      _fx_make_T2N10Ast__pat_tB(v_42, false, fx_result);

   _fx_catch_23: ;
      _fx_free_T2R9Ast__id_tLT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&v_41);
      if (relems_found_0) {
         _fx_free_LT4R16Ast__val_flags_tR9Ast__id_tN10Ast__typ_tN10Ast__exp_t(&relems_found_0);
      }
      if (new_relems_0) {
         _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&new_relems_0);
      }
      if (relems_1) {
         _fx_free_LT2R9Ast__id_tN10Ast__pat_t(&relems_1);
      }
      if (v_42) {
         _fx_free_N10Ast__pat_t(&v_42);
      }
      if (fx_status < 0) {
         fx_exn_get_and_reset(fx_status, &exn_0);
         fx_status = 0;
         _fx_free_T2N10Ast__pat_tB(fx_result);
         if (exn_0.tag == _FX_EXN_E17Ast__CompileError) {
            bool res_8;
            FX_CALL(_fx_M13Ast_typecheckFM6issomeB1Nt6option1R9Ast__id_t(rn_opt_0, &res_8, 0), _fx_catch_25);
            if (res_8) {
               _fx_N10Ast__pat_t v_54 = 0;
               _fx_LN10Ast__pat_t v_55 = 0;
               _fx_N10Ast__pat_t v_56 = 0;
               _fx_R9Ast__id_t v_57;
               FX_CALL(
                  _fx_M13Ast_typecheckFM8value_orR9Ast__id_t2Nt6option1R9Ast__id_tR9Ast__id_t(rn_opt_0, &_fx_g9Ast__noid, &v_57,
                     0), _fx_catch_24);
               FX_CALL(
                  _fx_M3AstFM9PatRecordN10Ast__pat_t3Nt6option1RM4id_tLT2RM4id_tN10Ast__pat_tRM5loc_t(
                     &_fx_g21Ast_typecheck__None9_, relems_0, loc_4, &v_54), _fx_catch_24);
               FX_CALL(_fx_cons_LN10Ast__pat_t(v_54, 0, true, &v_55), _fx_catch_24);
               FX_CALL(_fx_M3AstFM10PatVariantN10Ast__pat_t3RM4id_tLN10Ast__pat_tRM5loc_t(&v_57, v_55, loc_4, &v_56),
                  _fx_catch_24);
               FX_CALL(
                  _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
                     v_56, t_0, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0,
                     sc_0, simple_pat_mode_0, fx_result, 0), _fx_catch_24);

            _fx_catch_24: ;
               if (v_56) {
                  _fx_free_N10Ast__pat_t(&v_56);
               }
               if (v_55) {
                  _fx_free_LN10Ast__pat_t(&v_55);
               }
               if (v_54) {
                  _fx_free_N10Ast__pat_t(&v_54);
               }
               goto _fx_endmatch_2;
            }
         }
         FX_RETHROW(&exn_0, _fx_catch_25);

      _fx_endmatch_2: ;
         FX_CHECK_EXN(_fx_catch_25);
      }

   _fx_catch_25: ;
      fx_free_exn(&exn_0);
   }
   else if (tag_0 == 7) {
      _fx_N10Ast__typ_t t1_0 = 0;
      _fx_N10Ast__typ_t t2_0 = 0;
      fx_exn_t v_58 = {0};
      _fx_T2N10Ast__pat_tB v_59 = {0};
      _fx_N10Ast__pat_t p1_0 = 0;
      _fx_T2N10Ast__pat_tB v_60 = {0};
      _fx_N10Ast__pat_t p2_0 = 0;
      _fx_N10Ast__pat_t v_61 = 0;
      _fx_T3N10Ast__pat_tN10Ast__pat_tR10Ast__loc_t* vcase_5 = &p_0->u.PatCons;
      _fx_R10Ast__loc_t* loc_5 = &vcase_5->t2;
      FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&t1_0, 0), _fx_catch_26);
      FX_CALL(_fx_M3AstFM7TypListN10Ast__typ_t1N10Ast__typ_t(t1_0, &t2_0), _fx_catch_26);
      if (simple_pat_mode_0) {
         fx_str_t slit_16 = FX_MAKE_STR("\'::\' pattern is not allowed here");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_5, &slit_16, &v_58, 0), _fx_catch_26);
         FX_THROW(&v_58, false, _fx_catch_26);
      }
      fx_str_t slit_17 = FX_MAKE_STR("\'::\' pattern is used with non-list type");
      FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t_0, t2_0, loc_5, &slit_17, 0),
         _fx_catch_26);
      FX_CALL(
         _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
            vcase_5->t0, t1_0, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
            simple_pat_mode_0, &v_59, 0), _fx_catch_26);
      FX_COPY_PTR(v_59.t0, &p1_0);
      FX_CALL(
         _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
            vcase_5->t1, t2_0, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
            simple_pat_mode_0, &v_60, 0), _fx_catch_26);
      FX_COPY_PTR(v_60.t0, &p2_0);
      FX_CALL(_fx_M3AstFM7PatConsN10Ast__pat_t3N10Ast__pat_tN10Ast__pat_tRM5loc_t(p1_0, p2_0, loc_5, &v_61), _fx_catch_26);
      _fx_make_T2N10Ast__pat_tB(v_61, false, fx_result);

   _fx_catch_26: ;
      if (v_61) {
         _fx_free_N10Ast__pat_t(&v_61);
      }
      if (p2_0) {
         _fx_free_N10Ast__pat_t(&p2_0);
      }
      _fx_free_T2N10Ast__pat_tB(&v_60);
      if (p1_0) {
         _fx_free_N10Ast__pat_t(&p1_0);
      }
      _fx_free_T2N10Ast__pat_tB(&v_59);
      fx_free_exn(&v_58);
      if (t2_0) {
         _fx_free_N10Ast__typ_t(&t2_0);
      }
      if (t1_0) {
         _fx_free_N10Ast__typ_t(&t1_0);
      }
   }
   else if (tag_0 == 8) {
      _fx_T2N10Ast__pat_tB v_62 = {0};
      _fx_N10Ast__pat_t p1_new_0 = 0;
      _fx_N10Ast__pat_t v_63 = 0;
      _fx_T3N10Ast__pat_tR9Ast__id_tR10Ast__loc_t* vcase_6 = &p_0->u.PatAs;
      _fx_R10Ast__loc_t* loc_6 = &vcase_6->t2;
      FX_CALL(
         _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
            vcase_6->t0, t_0, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
            simple_pat_mode_0, &v_62, 0), _fx_catch_27);
      FX_COPY_PTR(v_62.t0, &p1_new_0);
      bool typed_1 = v_62.t1;
      _fx_R9Ast__id_t i_new_0;
      FX_CALL(
         _fx_M13Ast_typecheckFM10process_idR9Ast__id_t9R9Ast__id_tN10Ast__typ_tR10Ast__loc_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_tLN12Ast__scope_t(
            &vcase_6->t1, t_0, loc_6, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, sc_0,
            &i_new_0, 0), _fx_catch_27);
      FX_CALL(_fx_M3AstFM5PatAsN10Ast__pat_t3N10Ast__pat_tRM4id_tRM5loc_t(p1_new_0, &i_new_0, loc_6, &v_63), _fx_catch_27);
      _fx_make_T2N10Ast__pat_tB(v_63, typed_1, fx_result);

   _fx_catch_27: ;
      if (v_63) {
         _fx_free_N10Ast__pat_t(&v_63);
      }
      if (p1_new_0) {
         _fx_free_N10Ast__pat_t(&p1_new_0);
      }
      _fx_free_T2N10Ast__pat_tB(&v_62);
   }
   else if (tag_0 == 9) {
      _fx_Nt6option1rRt6Set__t1R9Ast__id_t v_64 = {0};
      _fx_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_65 = {0};
      _fx_N10Ast__typ_t t1_new_0 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_0 = {0};
      _fx_T2N10Ast__pat_tB v_66 = {0};
      _fx_N10Ast__pat_t p1_1 = 0;
      _fx_N10Ast__pat_t v_67 = 0;
      _fx_T3N10Ast__pat_tN10Ast__typ_tR10Ast__loc_t* vcase_7 = &p_0->u.PatTyped;
      _fx_R10Ast__loc_t* loc_7 = &vcase_7->t2;
      if (proto_mode_0) {
         _fx_M13Ast_typecheckFM4SomeNt6option1rRt6Set__t1R9Ast__id_t1rRt6Set__t1R9Ast__id_t(r_typ_vars_0, &v_64);
      }
      else {
         _fx_copy_Nt6option1rRt6Set__t1R9Ast__id_t(&_fx_g21Ast_typecheck__None5_, &v_64);
      }
      FX_CALL(
         _fx_M13Ast_typecheckFM30check_typ_and_collect_typ_varsT2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t6N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tNt6option1rRt6Set__t1R9Ast__id_tLN12Ast__scope_tR10Ast__loc_tB(
            vcase_7->t1, r_env_0, &v_64, sc_0, loc_7, !proto_mode_0, &v_65, 0), _fx_catch_28);
      FX_COPY_PTR(v_65.t0, &t1_new_0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_65.t1, &env1_0);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(r_env_0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0, r_env_0);
      fx_str_t slit_18 = FX_MAKE_STR("inconsistent explicit type specification");
      FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t1_new_0, t_0, loc_7, &slit_18, 0),
         _fx_catch_28);
      FX_CALL(
         _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
            vcase_7->t0, t_0, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
            simple_pat_mode_0, &v_66, 0), _fx_catch_28);
      FX_COPY_PTR(v_66.t0, &p1_1);
      FX_CALL(_fx_M3AstFM8PatTypedN10Ast__pat_t3N10Ast__pat_tN10Ast__typ_tRM5loc_t(p1_1, t1_new_0, loc_7, &v_67), _fx_catch_28);
      _fx_make_T2N10Ast__pat_tB(v_67, true, fx_result);

   _fx_catch_28: ;
      if (v_67) {
         _fx_free_N10Ast__pat_t(&v_67);
      }
      if (p1_1) {
         _fx_free_N10Ast__pat_t(&p1_1);
      }
      _fx_free_T2N10Ast__pat_tB(&v_66);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0);
      if (t1_new_0) {
         _fx_free_N10Ast__typ_t(&t1_new_0);
      }
      _fx_free_T2N10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_65);
      _fx_free_Nt6option1rRt6Set__t1R9Ast__id_t(&v_64);
   }
   else if (tag_0 == 12) {
      _fx_N10Ast__typ_t t1_1 = 0;
      _fx_N10Ast__typ_t v_68 = 0;
      _fx_T2N10Ast__pat_tB v_69 = {0};
      _fx_N10Ast__pat_t p1_2 = 0;
      _fx_N10Ast__pat_t v_70 = 0;
      _fx_T2N10Ast__pat_tR10Ast__loc_t* vcase_8 = &p_0->u.PatRef;
      _fx_R10Ast__loc_t* loc_8 = &vcase_8->t1;
      FX_CALL(_fx_M3AstFM12make_new_typN10Ast__typ_t0(&t1_1, 0), _fx_catch_29);
      FX_CALL(_fx_M3AstFM6TypRefN10Ast__typ_t1N10Ast__typ_t(t1_1, &v_68), _fx_catch_29);
      fx_str_t slit_19 = FX_MAKE_STR("\'ref\' pattern is used with non-reference type");
      FX_CALL(_fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(t_0, v_68, loc_8, &slit_19, 0),
         _fx_catch_29);
      FX_CALL(
         _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
            vcase_8->t0, t1_1, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
            simple_pat_mode_0, &v_69, 0), _fx_catch_29);
      FX_COPY_PTR(v_69.t0, &p1_2);
      bool typed_2 = v_69.t1;
      FX_CALL(_fx_M3AstFM6PatRefN10Ast__pat_t2N10Ast__pat_tRM5loc_t(p1_2, loc_8, &v_70), _fx_catch_29);
      _fx_make_T2N10Ast__pat_tB(v_70, typed_2, fx_result);

   _fx_catch_29: ;
      if (v_70) {
         _fx_free_N10Ast__pat_t(&v_70);
      }
      if (p1_2) {
         _fx_free_N10Ast__pat_t(&p1_2);
      }
      _fx_free_T2N10Ast__pat_tB(&v_69);
      if (v_68) {
         _fx_free_N10Ast__typ_t(&v_68);
      }
      if (t1_1) {
         _fx_free_N10Ast__typ_t(&t1_1);
      }
   }
   else if (tag_0 == 10) {
      _fx_T2N10Ast__pat_tB v_71 = {0};
      _fx_N10Ast__pat_t p1_3 = 0;
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_72 = {0};
      _fx_N10Ast__typ_t etyp_0 = 0;
      _fx_N10Ast__exp_t e1_0 = 0;
      _fx_N10Ast__pat_t v_73 = 0;
      _fx_T3N10Ast__pat_tN10Ast__exp_tR10Ast__loc_t* vcase_9 = &p_0->u.PatWhen;
      _fx_R10Ast__loc_t* loc_9 = &vcase_9->t2;
      _fx_N10Ast__exp_t e1_1 = vcase_9->t1;
      FX_CALL(
         _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
            vcase_9->t0, t_0, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
            simple_pat_mode_0, &v_71, 0), _fx_catch_30);
      FX_COPY_PTR(v_71.t0, &p1_3);
      FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e1_1, &v_72, 0), _fx_catch_30);
      FX_COPY_PTR(v_72.t0, &etyp_0);
      fx_str_t slit_20 = FX_MAKE_STR("\'when\' clause should have boolean type");
      FX_CALL(
         _fx_M13Ast_typecheckFM5unifyv4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tS(etyp_0, _fx_g22Ast_typecheck__TypBool, loc_9,
            &slit_20, 0), _fx_catch_30);
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
            e1_1, r_env_0, sc_0, &e1_0, 0), _fx_catch_30);
      FX_CALL(_fx_M3AstFM7PatWhenN10Ast__pat_t3N10Ast__pat_tN10Ast__exp_tRM5loc_t(p1_3, e1_0, loc_9, &v_73), _fx_catch_30);
      _fx_make_T2N10Ast__pat_tB(v_73, false, fx_result);

   _fx_catch_30: ;
      if (v_73) {
         _fx_free_N10Ast__pat_t(&v_73);
      }
      if (e1_0) {
         _fx_free_N10Ast__exp_t(&e1_0);
      }
      if (etyp_0) {
         _fx_free_N10Ast__typ_t(&etyp_0);
      }
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_72);
      if (p1_3) {
         _fx_free_N10Ast__pat_t(&p1_3);
      }
      _fx_free_T2N10Ast__pat_tB(&v_71);
   }
   else if (tag_0 == 11) {
      fx_exn_t v_74 = {0};
      _fx_LN10Ast__pat_t pl1_0 = 0;
      _fx_LN10Ast__pat_t pl_5 = 0;
      _fx_N10Ast__pat_t v_75 = 0;
      _fx_T2LN10Ast__pat_tR10Ast__loc_t* vcase_10 = &p_0->u.PatAlt;
      _fx_R10Ast__loc_t* loc_10 = &vcase_10->t1;
      if (simple_pat_mode_0) {
         fx_str_t slit_21 = FX_MAKE_STR("\'|\' pattern is not allowed here");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(loc_10, &slit_21, &v_74, 0), _fx_catch_32);
         FX_THROW(&v_74, false, _fx_catch_32);
      }
      _fx_LN10Ast__pat_t lstend_6 = 0;
      FX_COPY_PTR(vcase_10->t0, &pl_5);
      _fx_LN10Ast__pat_t lst_10 = pl_5;
      for (; lst_10; lst_10 = lst_10->tl) {
         _fx_T2N10Ast__pat_tB v_76 = {0};
         _fx_N10Ast__pat_t p_7 = lst_10->hd;
         FX_CALL(
            _fx_M13Ast_typecheckFM10check_pat_T2N10Ast__pat_tB10N10Ast__pat_tN10Ast__typ_tR16Ast__val_flags_tiBrRt6Map__t2R9Ast__id_tLN16Ast__env_entry_trRt6Set__t1R9Ast__id_trRt6Set__t1R9Ast__id_tLN12Ast__scope_tB(
               p_7, t_0, captured_val_flags_0, curr_m_idx_0, proto_mode_0, r_env_ref_0, r_idset_ref_0, r_typ_vars_0, sc_0,
               simple_pat_mode_0, &v_76, 0), _fx_catch_31);
         _fx_LN10Ast__pat_t node_6 = 0;
         FX_CALL(_fx_cons_LN10Ast__pat_t(v_76.t0, 0, false, &node_6), _fx_catch_31);
         FX_LIST_APPEND(pl1_0, lstend_6, node_6);

      _fx_catch_31: ;
         _fx_free_T2N10Ast__pat_tB(&v_76);
         FX_CHECK_EXN(_fx_catch_32);
      }
      FX_CALL(_fx_M3AstFM6PatAltN10Ast__pat_t2LN10Ast__pat_tRM5loc_t(pl1_0, loc_10, &v_75), _fx_catch_32);
      _fx_make_T2N10Ast__pat_tB(v_75, false, fx_result);

   _fx_catch_32: ;
      if (v_75) {
         _fx_free_N10Ast__pat_t(&v_75);
      }
      if (pl_5) {
         _fx_free_LN10Ast__pat_t(&pl_5);
      }
      if (pl1_0) {
         _fx_free_LN10Ast__pat_t(&pl1_0);
      }
      fx_free_exn(&v_74);
   }
   else {
      FX_FAST_THROW(FX_EXN_NoMatchError, _fx_cleanup);
   }

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM11check_casesLT2N10Ast__pat_tN10Ast__exp_t6LT2N10Ast__pat_tN10Ast__exp_tN10Ast__typ_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tR10Ast__loc_t(
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t* cases_0,
   struct _fx_N10Ast__typ_t_data_t* inptyp_0,
   struct _fx_N10Ast__typ_t_data_t* outtyp_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* env_0,
   struct _fx_LN12Ast__scope_t_data_t* sc_0,
   struct _fx_R10Ast__loc_t* loc_0,
   struct _fx_LT2N10Ast__pat_tN10Ast__exp_t_data_t** fx_result,
   void* fx_fv)
{
   int fx_status = 0;
   FX_CALL(fx_check_stack(), _fx_cleanup);
   int_ curr_m_idx_0;
   FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(sc_0, &curr_m_idx_0, 0), _fx_cleanup);
   _fx_LT2N10Ast__pat_tN10Ast__exp_t lstend_0 = 0;
   _fx_LT2N10Ast__pat_tN10Ast__exp_t lst_0 = cases_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N10Ast__pat_t p_0 = 0;
      _fx_N10Ast__exp_t e_0 = 0;
      _fx_LN12Ast__scope_t case_sc_0 = 0;
      _fx_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB v_0 = {0};
      _fx_N10Ast__pat_t p1_0 = 0;
      _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env1_0 = {0};
      _fx_T2N10Ast__typ_tR10Ast__loc_t v_1 = {0};
      _fx_N10Ast__typ_t e1_typ_0 = 0;
      fx_exn_t v_2 = {0};
      _fx_N10Ast__exp_t v_3 = 0;
      _fx_T2N10Ast__pat_tN10Ast__exp_t tup_0 = {0};
      _fx_T2N10Ast__pat_tN10Ast__exp_t* __pat___0 = &lst_0->hd;
      FX_COPY_PTR(__pat___0->t0, &p_0);
      FX_COPY_PTR(__pat___0->t1, &e_0);
      _fx_N12Ast__scope_t v_4;
      FX_CALL(_fx_M3AstFM15new_block_scopeN12Ast__scope_t1i(curr_m_idx_0, &v_4, 0), _fx_catch_0);
      FX_CALL(_fx_cons_LN12Ast__scope_t(&v_4, sc_0, true, &case_sc_0), _fx_catch_0);
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_patT5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB9N10Ast__pat_tN10Ast__typ_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tLN12Ast__scope_tBBB(
            p_0, inptyp_0, env_0, &_fx_g16Ast__empty_idset, &_fx_g16Ast__empty_idset, case_sc_0, false, false, false, &v_0, 0),
         _fx_catch_0);
      FX_COPY_PTR(v_0.t0, &p1_0);
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_0.t1, &env1_0);
      FX_CALL(_fx_M3AstFM11get_exp_ctxT2N10Ast__typ_tRM5loc_t1N10Ast__exp_t(e_0, &v_1, 0), _fx_catch_0);
      FX_COPY_PTR(v_1.t0, &e1_typ_0);
      _fx_R10Ast__loc_t e1_loc_0 = v_1.t1;
      bool v_5;
      FX_CALL(
         _fx_M13Ast_typecheckFM11maybe_unifyB4N10Ast__typ_tN10Ast__typ_tR10Ast__loc_tB(e1_typ_0, outtyp_0, &e1_loc_0, true,
            &v_5, 0), _fx_catch_0);
      if (!v_5) {
         fx_str_t slit_0 =
            FX_MAKE_STR("the case expression type does not match the whole expression type (or the type of previous case(s))");
         FX_CALL(_fx_M3AstFM11compile_errE2RM5loc_tS(&e1_loc_0, &slit_0, &v_2, 0), _fx_catch_0);
         FX_THROW(&v_2, false, _fx_catch_0);
      }
      FX_CALL(
         _fx_M13Ast_typecheckFM9check_expN10Ast__exp_t3N10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_t(
            e_0, &env1_0, case_sc_0, &v_3, 0), _fx_catch_0);
      _fx_make_T2N10Ast__pat_tN10Ast__exp_t(p1_0, v_3, &tup_0);
      _fx_LT2N10Ast__pat_tN10Ast__exp_t node_0 = 0;
      FX_CALL(_fx_cons_LT2N10Ast__pat_tN10Ast__exp_t(&tup_0, 0, false, &node_0), _fx_catch_0);
      FX_LIST_APPEND(*fx_result, lstend_0, node_0);

   _fx_catch_0: ;
      _fx_free_T2N10Ast__pat_tN10Ast__exp_t(&tup_0);
      if (v_3) {
         _fx_free_N10Ast__exp_t(&v_3);
      }
      fx_free_exn(&v_2);
      if (e1_typ_0) {
         _fx_free_N10Ast__typ_t(&e1_typ_0);
      }
      _fx_free_T2N10Ast__typ_tR10Ast__loc_t(&v_1);
      _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env1_0);
      if (p1_0) {
         _fx_free_N10Ast__pat_t(&p1_0);
      }
      _fx_free_T5N10Ast__pat_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Set__t1R9Ast__id_tRt6Set__t1R9Ast__id_tB(&v_0);
      FX_FREE_LIST_SIMPLE(&case_sc_0);
      if (e_0) {
         _fx_free_N10Ast__exp_t(&e_0);
      }
      if (p_0) {
         _fx_free_N10Ast__pat_t(&p_0);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }

_fx_cleanup: ;
   return fx_status;
}

FX_EXTERN_C int _fx_M13Ast_typecheckFM9check_modv1i(int_ m_idx_0, void* fx_fv)
{
   _fx_N16Ast__defmodule_t minfo_0 = 0;
   fx_exn_t exn_0 = {0};
   int fx_status = 0;
   FX_CALL(_fx_M3AstFM10get_moduleN16Ast__defmodule_t1i(m_idx_0, &minfo_0, 0), _fx_cleanup);
   _fx_LN12Ast__scope_t modsc_0 = 0;
   _fx_N14Ast__id_info_t v_0 = {0};
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_0 = {0};
   _fx_LN10Ast__exp_t v_1 = 0;
   _fx_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t v_2 = {0};
   _fx_LN10Ast__exp_t seq_0 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_1 = {0};
   _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t
      __lambda___0 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_3 = 0;
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t env_2 = {0};
   _fx_N12Ast__scope_t v_4;
   _fx_M3AstFM8ScModuleN12Ast__scope_t1i(m_idx_0, &v_4);
   FX_CALL(_fx_cons_LN12Ast__scope_t(&v_4, 0, true, &modsc_0), _fx_catch_3);
   _fx_R9Ast__id_t mname_0 = minfo_0->u.defmodule_t.t0;
   _fx_R9Ast__id_t mname1_0;
   FX_CALL(_fx_M3AstFM6dup_idRM4id_t2iRM4id_t(m_idx_0, &mname_0, &mname1_0, 0), _fx_catch_3);
   _fx_M3AstFM8IdModuleN14Ast__id_info_t1i(m_idx_0, &v_0);
   FX_CALL(_fx_M3AstFM12set_id_entryv2RM4id_tN14Ast__id_info_t(&mname1_0, &v_0, 0), _fx_catch_3);
   FX_CALL(
      _fx_M13Ast_typecheckFM13add_id_to_envRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tR9Ast__id_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
         &mname_0, &mname1_0, &_fx_g14Ast__empty_env, &env_0, 0), _fx_catch_3);
   FX_COPY_PTR(minfo_0->u.defmodule_t.t4, &v_1);
   FX_CALL(
      _fx_M13Ast_typecheckFM10check_eseqT2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t4LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tLN12Ast__scope_tB(
         v_1, &env_0, modsc_0, false, &v_2, 0), _fx_catch_3);
   FX_COPY_PTR(v_2.t0, &seq_0);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_2.t1, &env_1);
   _fx_R10Ast__loc_t last_loc_0;
   if (seq_0 != 0) {
      _fx_N10Ast__exp_t result_0 = 0;
      _fx_LN10Ast__exp_t __pat___0 = 0;
      _fx_N10Ast__exp_t v_5 = 0;
      FX_COPY_PTR(seq_0, &__pat___0);
      for (;;) {
         _fx_LN10Ast__exp_t __pat___1 = 0;
         FX_COPY_PTR(__pat___0, &__pat___1);
         if (__pat___1 != 0) {
            if (__pat___1->tl == 0) {
               _fx_N10Ast__exp_t result_1 = 0;
               FX_COPY_PTR(__pat___1->hd, &result_1);
               _fx_free_N10Ast__exp_t(&result_0);
               FX_COPY_PTR(result_1, &result_0);
               FX_BREAK(_fx_catch_0);

            _fx_catch_0: ;
               if (result_1) {
                  _fx_free_N10Ast__exp_t(&result_1);
               }
               goto _fx_endmatch_0;
            }
         }
         if (__pat___1 != 0) {
            _fx_LN10Ast__exp_t* rest_0 = &__pat___1->tl;
            _fx_free_LN10Ast__exp_t(&__pat___0);
            FX_COPY_PTR(*rest_0, &__pat___0);
            goto _fx_endmatch_0;
         }
         FX_FAST_THROW(FX_EXN_NullListError, _fx_catch_1);

      _fx_endmatch_0: ;
         FX_CHECK_EXN(_fx_catch_1);

      _fx_catch_1: ;
         if (__pat___1) {
            _fx_free_LN10Ast__exp_t(&__pat___1);
         }
         FX_CHECK_BREAK();
         FX_CHECK_EXN(_fx_catch_2);
      }
      FX_COPY_PTR(result_0, &v_5);
      FX_CALL(_fx_M3AstFM11get_exp_locRM5loc_t1N10Ast__exp_t(v_5, &last_loc_0, 0), _fx_catch_2);

   _fx_catch_2: ;
      if (v_5) {
         _fx_free_N10Ast__exp_t(&v_5);
      }
      if (__pat___0) {
         _fx_free_LN10Ast__exp_t(&__pat___0);
      }
      if (result_0) {
         _fx_free_N10Ast__exp_t(&result_0);
      }
   }
   else {
      last_loc_0 = _fx_g10Ast__noloc;
   }
   FX_CHECK_EXN(_fx_catch_3);
   _fx_M13Ast_typecheckFM7make_fpFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t2R10Ast__loc_ti(
      &last_loc_0, m_idx_0, &__lambda___0);
   FX_COPY_PTR(env_1.root, &v_3);
   FX_CALL(
      _fx_M13Ast_typecheckFM7update_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
         v_3, &__lambda___0, &_fx_g14Ast__empty_env, &env_2, 0), _fx_catch_3);
   FX_CHKIDX(FX_CHKIDX1(_fx_g16Ast__all_modules, 0, m_idx_0), _fx_catch_3);
   _fx_LN10Ast__exp_t* v_6 = &(*FX_PTR_1D(_fx_N16Ast__defmodule_t, _fx_g16Ast__all_modules, m_idx_0))->u.defmodule_t.t4;
   _fx_free_LN10Ast__exp_t(v_6);
   FX_COPY_PTR(seq_0, v_6);
   FX_CHKIDX(FX_CHKIDX1(_fx_g16Ast__all_modules, 0, m_idx_0), _fx_catch_3);
   _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* v_7 =
      &(*FX_PTR_1D(_fx_N16Ast__defmodule_t, _fx_g16Ast__all_modules, m_idx_0))->u.defmodule_t.t6;
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(v_7);
   _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2, v_7);

_fx_catch_3: ;
   FX_FREE_LIST_SIMPLE(&modsc_0);
   _fx_free_N14Ast__id_info_t(&v_0);
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_0);
   if (v_1) {
      _fx_free_LN10Ast__exp_t(&v_1);
   }
   _fx_free_T2LN10Ast__exp_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
   if (seq_0) {
      _fx_free_LN10Ast__exp_t(&seq_0);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_1);
   FX_FREE_FP(&__lambda___0);
   if (v_3) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_3);
   }
   _fx_free_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(&env_2);
   if (fx_status < 0) {
      fx_exn_get_and_reset(fx_status, &exn_0);
      fx_status = 0;
      int tag_0 = exn_0.tag;
      if (tag_0 == _FX_EXN_E17Ast__CompileError) {
         FX_CALL(_fx_M3AstFM16push_compile_errv1E(&exn_0, 0), _fx_catch_4);  _fx_catch_4: ;
      }
      else if (tag_0 != _FX_EXN_E26Ast__PropagateCompileError) {
         FX_RETHROW(&exn_0, _fx_cleanup);
      }
      FX_CHECK_EXN(_fx_cleanup);
   }

_fx_cleanup: ;
   if (minfo_0) {
      _fx_free_N16Ast__defmodule_t(&minfo_0);
   }
   fx_free_exn(&exn_0);
   return fx_status;
}

static int
   _fx_M13Ast_typecheckFM12__lambda__1_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(
   struct _fx_R9Ast__id_t* n_0,
   struct _fx_LN16Ast__env_entry_t_data_t* entries_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* new_env_0,
   struct _fx_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t* fx_result,
   void* fx_fv)
{
   _fx_LN16Ast__env_entry_t new_entries_0 = 0;
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_1 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_2 = 0;
   _fx_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB v_3 = {0};
   _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t new_root_0 = 0;
   _fx_FPi2R9Ast__id_tR9Ast__id_t v_4 = {0};
   int fx_status = 0;
   _fx_M13Ast_typecheckFM12__lambda__1_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t*
      cv_0 =
      (_fx_M13Ast_typecheckFM12__lambda__1_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t*)
         fx_fv;
   _fx_LN16Ast__env_entry_t lstend_0 = 0;
   _fx_LN16Ast__env_entry_t lst_0 = entries_0;
   for (; lst_0; lst_0 = lst_0->tl) {
      _fx_N16Ast__env_entry_t x_0 = lst_0->hd;
      int tag_0 = FX_REC_VARIANT_TAG(x_0);
      bool v_5;
      if (tag_0 == 1) {
         _fx_N14Ast__id_info_t info_0 = {0};
         _fx_LN12Ast__scope_t v_6 = 0;
         FX_CALL(_fx_M3AstFM7id_infoN14Ast__id_info_t2RM4id_tRM5loc_t(&x_0->u.EnvId, &cv_0->t0, &info_0, 0), _fx_catch_0);
         FX_CALL(_fx_M3AstFM9get_scopeLN12Ast__scope_t1N14Ast__id_info_t(&info_0, &v_6, 0), _fx_catch_0);
         int_ host_m_0;
         FX_CALL(_fx_M3AstFM11curr_modulei1LN12Ast__scope_t(v_6, &host_m_0, 0), _fx_catch_0);
         bool is_private_0;
         FX_CALL(_fx_M3AstFM23get_idinfo_private_flagB1N14Ast__id_info_t(&info_0, &is_private_0, 0), _fx_catch_0);
         if (host_m_0 == cv_0->t1) {
            v_5 = !is_private_0;
         }
         else {
            v_5 = false;
         }

      _fx_catch_0: ;
         FX_FREE_LIST_SIMPLE(&v_6);
         _fx_free_N14Ast__id_info_t(&info_0);
      }
      else if (tag_0 == 2) {
         v_5 = false;
      }
      else {
         FX_FAST_THROW(FX_EXN_NoMatchError, _fx_catch_1);
      }
      FX_CHECK_EXN(_fx_catch_1);
      if (!v_5) {
         FX_CONTINUE(_fx_catch_1);
      }
      _fx_LN16Ast__env_entry_t node_0 = 0;
      FX_CALL(_fx_cons_LN16Ast__env_entry_t(x_0, 0, false, &node_0), _fx_catch_1);
      FX_LIST_APPEND(new_entries_0, lstend_0, node_0);

   _fx_catch_1: ;
      FX_CHECK_CONTINUE();
      FX_CHECK_EXN(_fx_cleanup);
   }
   if (new_entries_0 != 0) {
      FX_COPY_PTR(new_env_0->root, &v_0);
      FX_COPY_FP(&new_env_0->cmp, &v_1);
      FX_CALL(
         _fx_M13Ast_typecheckFM12add_to_tree_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t4Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tFPi2R9Ast__id_tR9Ast__id_t(
            v_0, n_0, new_entries_0, &v_1, &v_2, 0), _fx_cleanup);
      if ((v_2 != 0) + 1 == 2) {
         _fx_T5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t*
            vcase_0 = &v_2->u.Node;
         if (vcase_0->t0.tag == 1) {
            _fx_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t v_7 = 0;
            FX_CALL(
               _fx_M13Ast_typecheckFM4NodeNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t5N12Map__color_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tR9Ast__id_tLN16Ast__env_entry_tNt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(
                  &_fx_g20Ast_typecheck__Black, vcase_0->t1, &vcase_0->t2, vcase_0->t3, vcase_0->t4, &v_7), _fx_catch_2);
            _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_7, false, &v_3);

         _fx_catch_2: ;
            if (v_7) {
               _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_7);
            }
            goto _fx_endmatch_0;
         }
      }
      _fx_make_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(v_2, true, &v_3);

   _fx_endmatch_0: ;
      FX_CHECK_EXN(_fx_cleanup);
      FX_COPY_PTR(v_3.t0, &new_root_0);
      FX_COPY_FP(&new_env_0->cmp, &v_4);
      _fx_make_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_root_0, &v_4, fx_result);
   }
   else {
      _fx_copy_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t(new_env_0, fx_result);
   }

_fx_cleanup: ;
   if (new_entries_0) {
      _fx_free_LN16Ast__env_entry_t(&new_entries_0);
   }
   if (v_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_0);
   }
   FX_FREE_FP(&v_1);
   if (v_2) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&v_2);
   }
   _fx_free_T2Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_tB(&v_3);
   if (new_root_0) {
      _fx_free_Nt11Map__tree_t2R9Ast__id_tLN16Ast__env_entry_t(&new_root_0);
   }
   FX_FREE_FP(&v_4);
   return fx_status;
}

FX_EXTERN_C int
   _fx_M13Ast_typecheckFM7make_fpFPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t2R10Ast__loc_ti(
   struct _fx_R10Ast__loc_t* arg0,
   int_ arg1,
   struct _fx_FPRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t*
      fx_result)
{
   FX_MAKE_FP_IMPL_START(
      _fx_M13Ast_typecheckFM12__lambda__1_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t_cldata_t,
      fx_free,
      _fx_M13Ast_typecheckFM12__lambda__1_Rt6Map__t2R9Ast__id_tLN16Ast__env_entry_t3R9Ast__id_tLN16Ast__env_entry_tRt6Map__t2R9Ast__id_tLN16Ast__env_entry_t);
   fcv->t0 = *arg0;
   fcv->t1 = arg1;
   return 0;
}

FX_EXTERN_C int fx_init_Ast_typecheck(void)
{
   int fx_status = 0;
   return fx_status;
}

FX_EXTERN_C void fx_deinit_Ast_typecheck(void)
{

}

